This document explains about the AutoScaling and Load Balancing on Amazon AWS cloud.
8KMiles provides Cloud Computing Consulting services in following AWS technologies like Amazon EC2 , Elastic Cloud compute , Simple Storage Service , S3 , Simple Queue service , SQS, Simple DB, AutoScaling , Elastic Load Balancing , ELB, Amazon CloudWatch, Amazon CloudFront, Amazon MapReduce and SNS.
Visit us at www.8kmiles.com/cloud
1. Auto scaling solution in AWS cloud
Harish Ganesan Raghuraman Balachandran
Co Founder and CTO Principal Engineer
harish@8kmiles.com raghu@8kmiles.com
www.8kmiles.com
2. Objective
• Leveraging Auto Scaling and Elastic Load
Balancing of AWS
• Cluster and Session replication not in scope
3. Understanding Scaling
Infrastructure
cost $$
Too much capacity
Huge Cap-ex
You lost your
customers here
Predicted Demand
Actual Demand
Scale up Approach
Traditional scale out
Automated scaling
Source: Amazon AWS Time t
www.8kmiles.com
4. Auto Scaling Architecture
User n
User 2
User 1
Amazon Auto Scaling & Elastic Load Balancer ELB redirects requests to same
Web / APP server based on
Session Sticky Algorithm
Autoscaled Web /
App servers Web / App 1 Web / App 2 Web / App n All the Auto Scaled
Web/App Server s
talk to the same
DB machine
My SQL
www.8kmiles.com
5. Solution Components
• Elastic Block Storage (EBS) – server images
• Simple Storage Service (S3) – storing objects
as key value pair
• Simple Queue Service (SQS) – queue
• Elastic Load Balancer (ELB) – load balancer
• AutoScale – for scaling servers up and down
automatically
• SimpleDB – scalable database
www.8kmiles.com
6. Solution Components - EBS
• Elastic Block Storage (EBS)
– Amazon Elastic Block Store (EBS) provides block
level storage volumes for use with Amazon EC2
instances.
– Amazon EBS is particularly suited for applications
that require a database, file system, or access to
raw block level storage.
– Our Use case :Application executables ,
configurations and OS are installed in the EBS in
this reference architecture
www.8kmiles.com
7. Solution Components – S3
• Simple Storage Service (S3)
– Amazon S3 provides a simple web services
interface that can be used to store and retrieve
any amount of data, at any time, from anywhere
on the web.
– Our Use case : The files that are uploaded ,
reports generated are stored in S3
www.8kmiles.com
8. Solution Components – SQS
• Simple Queue Service (SQS)
– Amazon Simple Queue Service (Amazon SQS)
offers a reliable, highly scalable, hosted queue for
storing messages as they travel between
computers
– Our Use case : the Meta data about the files are
put on the queue for processing . The Background
services picks up the meta data from SQS and
accesess and processes the files from S3
www.8kmiles.com
9. Solution Components – Simple DB
• Simple DB
– Amazon SimpleDB is a highly available, scalable,
and flexible non-relational data store that offloads
the work of database administration. Developers
simply store and query data items via web
services requests
– Our Use case : The Status , Audit and inter
application information is stored in Simple DB
www.8kmiles.com
10. Solution Components – ELB
• Elastic Load Balancer (ELB)
– Elastic Load Balancing automatically distributes
incoming application traffic across multiple
Amazon EC2 instances.
– Elastic Load Balancing detects unhealthy instances
within a pool and automatically reroutes traffic to
healthy instances until the unhealthy instances
have been restored.
– Our Use case : Load Distributed among Servers
located in Multiple AZ and Dynamically Auto
Scaled EC2 instances www.8kmiles.com
11. Solution Components – Auto Scaling
• Auto Scaling
– Auto Scaling allows you to automatically scale
your Amazon EC2 capacity up or down according
to conditions you define.
– Auto Scaling is particularly well suited for
applications that experience hourly, daily, or
weekly variability in usage.
– Our Use case : EC2 Server instances dynamically
Scaled up and Down depending upon the Load
using the Auto scaling
www.8kmiles.com
12. Setup and Config
Create an Elastic Load Balancer
elb-create-lb my-load-balancer --headers --listener "lb-
port=80,instance-port=8080,protocol=HTTP" --availability-zones us-
east-1c
The load App server port to Add a name to your
balancer port which requests needs load balancer
to be forwarded
www.8kmiles.com
13. Setup and Config contd..
Create a launch configuration
Just a name to the AMI (server image) to be
launch config launched during scaling
as-create-launch-config my-launch-config --image-id ami-e3826c8a --
instance-type m1.small --key my-key-pair --group my-security-group
Instance Keypair and security
(server) size Group (firewall) for
the new servers
www.8kmiles.com
14. Setup and Config contd..
Create the auto scale group
Name your auto Min and Max number of
Scale group instances to be spawned
as-create-auto-scaling-group my-as-group --availability-zones us-east-
1c --launch-configuration my-launch-config --max-size 11 --min-size
3 --cooldown 180 --load-balancers my-load-balancer
Mention the launch Specify the load balancer to
config (the one we which the new servers needs
created in last step) to be attached
www.8kmiles.com
15. … and we are done
Configure the triggers
Measure the avg CPU Specify the autoscale
of the autoscale group group name
as-create-or-update-trigger my-as-trigger --auto-scaling-group my-as-group
--namespace "AWS/EC2" --measure CPUUtilization --statistic Average --
dimensions "AutoScalingGroupName= my-as-group " --period 60 --lower-
threshold 20 --upper-threshold 80 --lower-breach-increment"=-2" --upper-
breach-increment 4 --breach-duration 180
Scale down by 2 servers and
Lower CPU limit is 20% and
scale up by 4 servers
upper CPU limit is 80%
www.8kmiles.com
16. Use Case – Demo Application
• Image 1: Servers at initial Stage
• Image 2: Load Increases : Servers are ramped
up using Auto Scaling
• Image 3: Load Decreases
• Image 4: Servers are dynamically scaled down
using Auto Scaling
Demo screenshots attached in coming slides
www.8kmiles.com