Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid downtime with Elastic Beanstalk deployments including database patches?

I've read the AWS docs regarding Deploying Versions with Zero Downtime, aka CNAME swapping.

As yegor256 explains it in this answer:

The only thing that it does is just exchanging of two CNAMEs. For example, you have one environment foo-1 with CNAME foo-1.example.com, and another one foo-2 with CNAME foo-2.example.com. After swap operation environment foo-1 will respond at http://foo-2.example.com.

So the problem is, you're not switching the whole traffic straight away, but only the new traffic. Existing traffic will continue to use the previous CNAME entry for up to TTL seconds, making two versions coexist for this short period of time (300 seconds, or more according to Arun Kumar).

This looks acceptable to me when two versions of the application can cohabit.

However, some releases of our app include database patches, that must be run right after the old version has been taken out, and right before the new version is brought in.

So it looks like CNAME swapping is just not good enough for what we're doing, as the old app version would break after the database has been patched.

Ideally, I'd like to:

  • Always keep the same Elastic Load Balancer
  • Have Elastic Beanstalk boot up one or more instances with the new app version
  • Remove the existing instances (with the old app version) from the ELB
  • Patch the database
  • Add the freshly booted instances (with the new app version) to the ELB

This would minimize the downtime to just a few seconds of 503 Service Unavailable, only when there are patches to apply.

Is that possible? Or did I not see the whole picture properly, and am I missing a simpler solution?

like image 262
BenMorel Avatar asked Sep 17 '13 23:09

BenMorel


People also ask

Which Elastic Beanstalk deployment approaches allow you to maintain full capacity while performing an update?

To maintain full capacity during deployments, you can configure your environment to launch a new batch of instances before taking any instances out of service. This option is known as a rolling deployment with an additional batch.

When should you not use Elastic Beanstalk?

Elastic Beanstalk isn't great if you need a lot of environment variables. The simple reason is that Elastic Beanstalk has a hard limit of 4KB to store all key-value pairs. The environment had accumulated 74 environment variables — a few of them had exceedingly verbose names.

What two types of environments can be created when using Elastic Beanstalk?

In AWS Elastic Beanstalk, you can create a load-balanced, scalable environment or a single-instance environment.


1 Answers

Here are some other strategies that you can use to perform zero-downtime deployment on Elastic Beanstalk: http://www.hudku.com/blog/demystified-zero-downtime-with-amazon/

like image 97
Michael Gallego Avatar answered Oct 14 '22 23:10

Michael Gallego