Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Surviving a reboot with AWS CloudFront

We all know that CloudFlare has a feature where if your server is offline, it will start serving up a cached version of your website - whether something has gone terribly wrong, or whether you're doing a simple restart.

I've been searching the net high and low, of how to do the same thing with CloudFront but I just can't seem to be able to dig out any kind of resource in relation to this matter.

Do you have any pointers?

like image 585
Francis Kim Avatar asked Dec 22 '15 08:12

Francis Kim


People also ask

How long does it take to invalidate CloudFront?

Object invalidations typically take from 10 to 100 seconds to complete. You can check the status of an invalidation by viewing your distribution from the CloudFront console.

What happens when you reboot an EC2 instance?

When you reboot an instance, it keeps its public DNS name (IPv4), private and public IPv4 address, IPv6 address (if applicable), and any data on its instance store volumes. Rebooting an instance doesn't start a new instance billing period (with a minimum one-minute charge), unlike stopping and starting your instance.

How long does it take for CloudFront to propagate?

CloudFront can take up to 25 minutes to deploy. This is because CloudFront delivers content through a worldwide network of low latency and high performance edge locations. It can take additional time depending on how long it takes to propagate changes in configurations such as certificates, origins, settings and more.


1 Answers

The best idea is to put a load balancer (e.g. using Elastic Load Balancer) in front of your server and spin up another server which replicates your existing site. You can also use an Elastic IP Address to reroute traffic if a particular server falls offline.

You can then use a shared MySQL server (e.g. AWS RDS in a Multi-AZ configuration for extra redundancy) plus a GlusterFS to keep the website document root on both web servers in sync. DigitalOcean have a guide for this here: https://www.digitalocean.com/community/tutorials/automating-the-deployment-of-a-scalable-wordpress-site

I would highly recommend CloudFlare over AWS CloudFront, there are many other benefits CloudFlare has (e.g. CloudFlare has HTTP2 support where CloudFront does not).

like image 83
mjsa Avatar answered Oct 10 '22 03:10

mjsa