Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent downtime during AWS Elastic Beanstalk deployment of a new version of the app?

My understanding of Elastic Beanstalk is that when you deploy a new version of your app, that it deploys it to the Amazon EC2 instances one at a time (if you have more than one). However, even with a minimum of two instances, my application incurs a short amount of downtime when I upload a new .war when it is deploying it, as if it is updating them both simultaneously. Is there a way I can ensure there is no downtime and that one instance is fully updated and accepting requests before the next starts: Here is how the events look. Note this is with zero load on the app, so it will only get worse with production traffic.

INFO Environment update completed successfully.  INFO New application version was deployed to running EC2 instances.  ERROR The application did not respond at the health check URL.  INFO Waiting for 8 seconds while EC2 instances download the updated application version.  INFO Deploying version SomethingMore to 2 instance(s). 
like image 215
Peter Avatar asked Jul 16 '12 20:07

Peter


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.

How do I deploy without downtime?

Blue-Green Deployments A Blue-Green deployment is a relatively simple way to achieve zero downtime deployments by creating a new, separate environment for the new version being deployed and switching traffic into it. A rollback happens just as easily, with a traffic switch to the old version.

How many application versions does Elastic Beanstalk allow you to store?

Elastic Beanstalk applies an application's lifecycle policy each time you create a new application version, and deletes up to 100 versions each time the lifecycle policy is applied.


2 Answers

To achieve this goal in Elastic Beanstalk, you'll need to expand your deployment procedure to facilitate multiple Environments (see AWS Elastic Beanstalk Components):

An environment is a version that is deployed onto AWS resources. Each environment runs only a single version, however you can run the same version or different versions in many environments at the same time. [...] For more information about the environment and the resources that are created, see Architectural Overview. [emphasis mine]

This feature is useful for testing/debugging separate versions already, but specifically this enables hot swapping of environments as well, see Deploying Versions With Zero Downtime for a respective walkthrough:

Since AWS Elastic Beanstalk performs an in-place update when you update your application versions, you will experience some downtime. However, it is possible to avoid this downtime by swapping the CNAMEs for your environments. This section walks you through how to perform a CNAME swap using the AWS Management Console, the command line interface, or APIs. [emphasis mine]

like image 150
Steffen Opel Avatar answered Sep 22 '22 18:09

Steffen Opel


I know this is an old question, but for people googling (like me), Elastic Beanstalk released rolling application version deployments today (11/2/2014).

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.rolling-version-deploy.html?sc_ichannel=em&sc_icountry=global&sc_icampaigntype=launch&sc_icampaign=em_125873140&sc_idetail=em_14124901705&ref_=pe_411040_125873140_8

This allows you to update part of your fleet with your new application at a time, ensuring that there's always hosts available to take traffic.

like image 42
zongweil Avatar answered Sep 26 '22 18:09

zongweil