4

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!

ajporterfield
  • 1,009
  • 2
  • 10
  • 23
  • If an instance fails a health check then it is removed and replaced - do the notification emails say this is the case (there should be a reason given for the scaling activity?) – Frederick Cheung May 13 '14 at 04:59
  • There's nothing in the alarm emails about a failed health check. Just that... Threshold Crossed: 1 datapoint (337030.5) was less than the threshold (2000000.0). – ajporterfield May 13 '14 at 13:07
  • hey @ajporterfield do you have any solution for this post ? I have the same problem :/ – Nelson Patricio Jimenez Oct 11 '15 at 19:29
  • 1
    My "fix" was to just set max/min instance count to 1. Not much of a fix but my app really doesn't need crazy autoscaling anyways. When I need a second app server, I will just increase those to two. – ajporterfield Oct 13 '15 at 00:43

1 Answers1

0

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.

Brian
  • 5,300
  • 2
  • 26
  • 32