Dynamically Scale Web Applications in Amazon EC2

Ever since I started working on the Amazon cloud, I was stuck with one thing - not being able to scale the web applications dynamically. To be honest it didn’t even strike me until companies like Rightscale and Scalr started to come into the limelight. Until that time I was just trying to imitate the existing environment, just migrating to Amazon cloud. When I saw the demo of Rightscale and Scalr, I thought it was amazing, to be able to scale the applications dynamically with the click of a button. They have done a wonderful job of automating a whole lot of stuff without getting into the boxes and just using their web based administration application. So I thought what would it take to do a step 1 of what they do - automatically scale up or scale down an instance. I used simple shell scripts to make that happen. I created a white paper that explains the approach and what the scripts do. The white paper assumes Nginx is used for load balancing a web application and Nagios for monitoring the instances. The solution involves dynamically adding a new instance to the Nginx configuration for load balancing and adding the Nagios configuration for monitoring the new instance. It also removes the configurations from Nginx and Nagios when the instance is brought down.

Click the button below to download the zip file containing the white paper and the shell scripts.

Download Dynamically Scaling Web Applications in EC2.zip

This is just a first step to scaling the applications dynamically. It would still require someone to decide when the application needs to be scaled up or scaled down. But once that decision is made it is just a matter of bringing up or down the instances and the rest of the stuff is taken care of.

Feel free to pass on your comments and feedback.