How do I set up auto-scaling on an Amazon EC2 database?

I am deploying the rails application on EC2 instances where I want to configure the automatic scaling that will be used with the elastic load balancer. At a certain threshold, I want to create a new instance. When setting up a trigger for an auto-scaling group, we have options for using the CPU, Network, or disk IO; but as a rail application, I ran into a resource crunch in memory, not a processor or IO.

Has anyone configured EC2 auto-scaling for a rail application? What is the preferred way to use AWS with rails?

FYI: I am using a passenger application server.

Thank you for your time.

+4
source share
3 answers

I did not do this with Rails, but with java in Tomcat. We used tomcat valves / scripts to detect memory usage and publish it to Amazon cloudWatch as custom cloud monitoring metrics. You can create a zoom trigger based on a cloud alarm that tracks this metric.

Some sections of the aforementioned technique may be blocked for rails.

+1
source

Actually, I think you should try to customize your Passenger configuration based on the type of instance you are using (here's an article about it: http://blog.scoutapp.com/articles/2009/12/08/production-rails- tuning-with-passenger-passengermaxprocesses ). This should ensure that at full load you use all available RAM, but you do not create more copies for passengers than is available in RAM.

This, in my experience, leads to the saturation of all resources (CPU and RAM), and you can initiate an automatic policy based on CPU usage. You should also tune the instance type for maximum performance (I used the cc1.xlarge instance with sufficient success).

If you set up RAM-based autoscaling, you can create a metric in CloudWatch that monitors RAM usage and autoscales using this metric. Creating a metric is simply publishing metric data at regular intervals using the CloudWatch API ( http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/CloudWatch/Metric.html ). You can create a rails background task that runs every minute and publishes metric data.

+1
source

I think you can use the new alarm function, control the memory metric and start the instance using api:

http://aws.typepad.com/aws/2010/12/amazon-cloudwatch-alarms.html

0
source

Source: https://habr.com/ru/post/1312244/


All Articles