2
votes

I am surprised to find little information regarding EC2 autoscaling with Phusion Passenger.

I actually discovered not so long ago a metric "Requests in queue" being exposed upon running passenger-status

I am wondering whether this stat would make a nice metric to help with autoscaling.

Right now most AWS EC2 Autoscaling guides mention using CPU and Memory to write autoscaling rules but I find this insufficient. When I think about the problem autoscaling should solve, that is being able to scale up to the demand, I'd rather base those rules on the number of pending/completed requests to report a node health or a cluster congestion, and Passenger "Requests in queue" (and also for each process, the "Last Used" and "Processed" count) seems to useful.

I am wondering it it would be possible to report this "Requests in queue" stat (and eventually others) periodically as an AWS metric. I was thinking the following rule would be ideal for autoscaling : If the average number of "requests in queue" on the autoscaled instances is to exceed a threshold value, this would trigger spawning a new machine from the autoscaling group.

Is this possible ? Has anyone ever tried to implement autoscaling rules based on number of requests in queue this way ?

1

1 Answers

6
votes

This is totally possible (and a good approach).

Step 1. Create custom CloudWatch metric for "Requests in queue". You will have to write your own agent that runs passenger-status, extracts the value and sends it to CloudWatch. You can use any AWS SDK or just AWS CLI: http://docs.aws.amazon.com/cli/latest/reference/cloudwatch/put-metric-data.html

Step 2. Create alarms for scale up and scale down based on your custom metric.

Step 3. Modify scaling policy for your Auto Scaling Group to use your custom alarms to scale up/down.