How to , and other stuff about linux, photo, php … Another blog just like others on internet

October 22, 2014

mod_rpaf and Amazon ELB

Filed under: Linux — Tags: , , , — admin @ 11:26 am

Well is clear that if you want to use the amazon elb, you will not see the $REMOTE_ADDR correctly and you will need mor_rpaf enabled and installed.
If you have a centos / redhat server I found this nice tutorial on this page

mod_rpaf and Amazon ELB

And add this
LoadModule rpaf_module modules/

RPAFenable On
RPAFsethostname On
RPAFproxy_ips 10.
RPAFheader X-Forwarded-For

January 26, 2012

autoscaling with amazon ec2 and elb

Filed under: Linux — Tags: , , , , — admin @ 11:19 am

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 :
as-create-launch-config ec2elbconfig --image-id ami-xxxxx --instance-type m1.large --key key_name
Also if you don’t have already setup credentials you may append
-I amazonid -S secretkey
Do not forget to add –key because after the instance is up you won’t be able to log on it.

Next command is:
as-create-auto-scaling-group MyAutoScalingGroup --launch-configuration ec2elbconfig --availability-zones us-east-1c --min-size 2 --max-size 6 --load-balancers MyLoadBalancer

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:
[root@server]# as-put-scaling-policy HighCpuPolicy --auto-scaling-group MyAutoScalingGroup --adjustment=1 --type ChangeInCapacity --cooldown 300
[root@server]# as-put-scaling-policy LowCpuPolicy --auto-scaling-group MyAutoScalingGroup --adjustment=-1 --type ChangeInCapacity --cooldown 300

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:
mon-put-metric-alarm HighCpuAlarm --comparison-operator GreaterThanThreshold --evaluation-periods 4 --metric-name CPUUtilization --namespace "AWS/EC2" --period 60 --statistic Average --threshold 30 --alarm-actions arn:aws:autoscaling:us-east-1:xxx:scalingPolicy:xxx-xx-xx-xx-xxxxx:autoScalingGroupName/MyAutoScalingGroup:policyName/HighCpuPolicy --dimensions "AutoScalingGroupName=MyAutoScalingGroup"

mon-put-metric-alarm LowCpuAlarm --comparison-operator LessThanThreshold --evaluation-periods 4 --metric-name CPUUtilization --namespace "AWS/EC2" --period 60 --statistic Average --threshold 20 --alarm-actions arn:aws:autoscaling:us-east-1:xxx:scalingPolicy:xxx-xx-xx-xx-xxxxx:autoScalingGroupName/MyAutoScalingGroup:policyName/LowCpuPolicy --dimensions "AutoScalingGroupName=MyAutoScalingGroup"

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.

Powered by WordPress