Thursday, May 10, 2012

Load Balancing and Auto Scaling in AWS

Amazon ELB and AutoScaling

The Amazon Elastic Load Balancer Service supports HTTP and TCP requests. It now supports sticky sessions via cookies so it should be much more usable as many applications require sessions to be routed to the same server.
HTTPS is supported indirectly via using TCP and port 443. ELB directly forwards the TCP packets to the instance. Because support is at the TCP level, not at the HTTPS level, the ELB will not:
- perform SSL termination
- add an X-Forwarded-For header (which the HTTP listener does)
- optimize connections from your back-end instances using keepalive.
This means, for example, with HTTPS you cannot get the client's IP address from the X-Forwarded-For header as with HTTP

The Amazon Auto Scaling service uses CloudWatch as the monitoring mechanism for determining to scale up or down.

Costs of Elastic Load Balancers are from $0.025 hr ($18.25 mth) and a small cost for GB processed plus Cloudwatch cost per instance $0.015 hr ($10.95 mth). So this is typically cheaper than running load balancing on your instance.

Summary: Cheap, reliable, scalable bare bones scaling solution.


Scalr is another popular load balancing/scaling solution. It can be run from the Scalr website for $99 a month (it is creeping up in price from $50 a month) or you can run your own copy of Scalras it is open source. The website also provides some management features like scripting and SSH access.

The Scalr architecture is built around several Amazon Machine Images (Small or Large) and targets multi-tier applications
1. Load Balancer runnning Nginx for the load balancer. They also support HTTPS. It is possible to use other load balancers like Pound.
2. Application Server Image - LAMP/Java Tomcat/RubyOnRails.
3. MySQL Master/slave for the database.
You also need to do administration of Amazon EC2 through the Scalr platform.

Scalr has some nice features like time based scaling, auto deployment of updated Amazon Machine Images. They have some pre-defined machine images so if your application matches these it will be faster to setup. (NOTE: Currently Amazon's RDS does not support MySQL Master/Slave while Scalr does )

Summary: More features that Amazon Elastic Load Balancer/Auto Scaling. Still relatively cheap and open source so you can always run it yourself although easier to use through their website.

Cloud Foundry

Cloud Foundry is a great platform for deploying and auto scaling java applications. It is specify to Java applications supporting:
    Java 1.6
    Apache 2.2.3
    SpringSource tc Server (Tomcat 6)
    MySQL 5.0.45
    CentOS 5.2

The Apache HTTP Server load balances over the Tomcat servers and it uses Hyperic to monitor the servers and auto scale the Tomcat servers. It support MySql Master/slave configuration for scaling the database. The database is stored on an Amazon EBS and automatically backed up to S3. (Similar to Amazon RDS). Currently it is in extended beta and free.

Summary: The fastest way to deploy and run Java your applications. Restricted to their particular java software stack but a great platform if your application matches this stack.


RightScale was the first company to provide load balancing and Scaling of Amazon EC2. They are also the most expensive from $2500 up-front and $500 a month.
They have a powerful scripting and templating system and their platform is more comprehensive than Scalr. The scripting however is also complex and proprietary. They support other clouds like Rackspace etc.
RightScale provide an Apache+HAProxy setup for load balancing and also will automatically setup a MySql Master/Slave database as does Scalr.

Summary: If you have complex/large scalability requirements and Rightscale have pre-built scripts and templates for your application then they are a good option.


Makara provide scaling, monitoring and deployment of Java and PHP applications. Similar to Cloud Foundry in some ways. Now they are owned by Redhat good for Redhat and CentOS users.

Cloudkick provide management, auto scaling, monitoring and alerting. Now they have been acquired by Rackspace good for using with Rackspace cloud. 

Your Reviews/Queries Are Accepted