Creating an auto scaled system using an Amazon load balancer is an interesting task that I did recently.
Here are the list of commands that I used to setup from the command line :
Also if you don’t have already setup credentials you may append
Do not forget to add –key because after the instance is up you won’t be able to log on it.
Next command is:
Where : MyLoadBalancer – is the name of your ELB ( loading balancer ) from amazon
Nex we create two policy rules, one for adding server and one for remover:
arn:aws:autoscaling:us-east-1:xxx:scalingPolicy:xxx-xx-xx-xx-xxxxx:autoScalingGroupName/MyAutoScalingGroup:policyName/HighCpuPolicy
[root@server]# as-put-scaling-policy LowCpuPolicy --auto-scaling-group MyAutoScalingGroup --adjustment=-1 --type ChangeInCapacity --cooldown 300
arn:aws:autoscaling:us-east-1:xxx:scalingPolicy:xxx-xx-xx-xx-xxxxx:autoScalingGroupName/MyAutoScalingGroup:policyName/LowCpuPolicy
Here is important to remember the output.
After this we must create two monitor rules that will scale our balancer, so will need two more rules:
and
After this you will have allways 2 instance up, and if the load go up then 30% more then 4 minutes the system will go up with one more server, if the load go bellow 20% more then 4 minutes will remove one server from load balancer.
If you need to remove this you must delete rules from bottom to top using bellow commands with name of your rules.
as-delete-policy
as-delete-auto-scaling-group
as-delete-launch-config


