In this post (https://zoumana.wordpress.com/2014/06/16/zero-downtime-deploiement-sur-tomcat7/), i talked about the Zero Downtime deployment feature inside tomcat 7 and later.
To summary this was about deploying a newer version of the same app within the same tomcat container keeping the previous WAR serving the HTTP requests until the new version is successfully deployed to take over the next users’ requests.
Today the target is the same: avoiding to take an application off-line during an upgrade for the happiness of end users 🙂 but through one of Amazon Web Services feature: Elastic Load Balancer!
Here each application instance is deployed inside a EC2 instance alone (this usecase is not the same as the one above: we are going to deploy a complete new EC2 instance with the newer WAR and not deploying the newer WAR inside the same tomcat container)
First of all, let define some terms:
Blue Green Deployment: Upgrading a service by adding progressively newer application version instance inside the current application pool. Both version coexists: we increase N+1 instances and decrease N instances number. (CAUTION about database upgrades. I just think about it while writing but this is suitable for NoSQL app based)
Canary Deployment: Testing new features by adding into the service 1 newer application version instance. Suitable for UI features.
With ELB it’s very simple to achieve one of those deployment style whatever your purpose is: blue-green upgrade or feature testing one
While setting up an ELB: you have to setup the load balancing protocol part and then specify the EC2 instances that are part of your load balancing pool. You can dynamically add or remove instances for the ELB settings serving or no more serving requests to them.
During an upgrade:
- deploy your N+1 software instances
- migrate your schema if needed (CAUTION your database is supposed to support 2 frontends different code level)
- add 1 of the N+1 software based instance to the load balancer pool: it will then served requests
- analyze the end users feedbacks and also the application logs
- if everything is fine add others newer apps instances to the load balancer pool and remove the same number of old version app instances.
- redo this to remove all the instances for your previous app version.
You are done!