简体   繁体   中英

AWS Elastic Beanstalk Rails app autoscaling issues

I'm running into two distinct, but related, issues with a Rails app (Ruby 1.9.3) I have deployed on AWS' Elastic Beanstalk. I have the following autoscaling config applied. I believe it is the default.

  • Environment type: Load balanced, auto scaling
  • Number instances: 1 - 4
  • Scale based on Average network out
  • Add instance when > 6000000
  • Remove instance when < 2000000

Issue #1 - My app doesn't get very much traffic yet and only requires 1 EC2 instance (m1.medium). I get several "ElasticBeanstalk Default Scale Down alarm" emails from AWS each week. Most of the time, I check my app after receiving one, and it's fine; however, about once a month, I check my app after receiving the email and find the nginx 404 page. EB has terminated my EC2 instance - the only one running my app - and generated a new one. Why is it scaling down from 1 to 0? This has happened to me with consistency for the past 6 months. Has anyone else experienced this? Found a solution?

Issue #2 - When the above situation happens, EB creates a new EC2 instance for me. But, I continue to get the nginx 404 page until I re-deploy - which is a manual task and seems to defeat the purpose of auto scaling. Does EB require a re-deploy after autoscaling occurs? Shouldn't it automatically deploy the current/latest version of my app to the new EC2 instance(s)?

Any help/advice is greatly appreciated!

I've had exactly this issue! The problem is that the Remove instance when < 2000000 criteria is firing when you only have one instance. If your instance goes above 2000000 and then back down below 2000000, EB will terminate it and launch another one. Disable the autoscaling action for that alarm and your problem will go away.

With regards to your second issue - how long are you waiting for the newly built instance to become available? I have noticed that new instances will be added to the autoscaling group as soon as they are ready, but before EB has finished deploying your application. In your single-instance situation, that's especially bad since there are no valid servers for a few minutes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM