Skip to content

GSS CloudFront Origin Failover

Working Principle

If the primary origin is unavailable, or returns specific HTTP response status codes that indicate a failure, CloudFront automatically switches to the secondary origin.

    CloudFront does the following for viewer requests:
  • When there’s a cache hit, CloudFront returns the requested object.
  • When there’s a cache miss, CloudFront routes the request to the primary origin in the origin group.
  • When the primary origin returns a status code that is not configured for failover, such as an HTTP 2xx or 3xx status code, CloudFront serves the requested object to the viewer.
  • When any of the following occur:
    • The primary origin returns an HTTP status code that you’ve configured for failover
    • CloudFront fails to connect to the primary origin
    • The response from the primary origin takes too long (times out) Then CloudFront routes the request to the secondary origin in the origin group.

Note: CloudFront routes all incoming requests to the primary origin, even when a previous request failed over to the secondary origin. CloudFront only sends requests to the secondary origin after a request to the primary origin fails.

Implementation

  1. Create another origin for cloudfront distribution

cloudFront_failover_1.png

  1. Create origin group, select primary and secondary

cloudFront_failover_2.png

3. Edit a cache behavior to use the origin group

cloudFront_failover_3.png

Reference

https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/high_availability_origin_failover.html