DEV Community

fhorisberger for AWS Community Builders

Posted on

Cloudfront origin failover

This new article, we are speaking about CloudFront origin failover, it allows us to create a high avaliavility solutions when primary origin is unavailable.

Basic view:

CloudFront Origin Failover

If you don't have new cloudfront distribution please visit this site:Amazon Web Site for creating a new distribution

Then we should create an origin groups, it will be used for rerouting our request in the case that primary origin will have a failure.

An item important is CloudFront fails over to the secondary origin only when the HTTP method of the viewer request is GET, HEAD, or OPTIONS.

Creating an origin group:

1- Sign in to the AWS Management Console and open the CloudFront console at https://console.aws.amazon.com/cloudfront/v3/home

2- Choose the Origins tab.

3- Make sure the distribution has more than one origin. If it doesn’t, add a second origin.

4- On the Origins tab, in the Origin groups pane, choose Create origin group.

5- Choose the origins for the origin group. After you add origins, use the arrows to set the priority—that is, which origin is primary and which is secondary.

6- Enter a name for the origin group.

7- Choose the HTTP status codes to use as failover criteria. You can choose any combination of the following status codes: 400, 403, 404, 416, 500, 502, 503, or 504. When CloudFront receives a response with one of the status codes that you specify, it fails over to the secondary origin.

8- Create Origin Group

CreateOriginGroup

About origin timeouts and attempts:

By default, CF tries to connect to the primary origin for as long as 30 seconds (3 connection attempts of 10 seconds each) before moving to secondary origin. These values can be changed to timeouts between 1 and 10 seconds, attempts between 1 and 3 times

Top comments (0)