I have an Elastic Beanstalk application that is running a wordpress application, and I would like some monitoring and scaling triggers for when the health check, the homepage, returns an HTTP response code within the range of 4xx and 5xx. I am aware of monitoring tab and the capacity tab from the configuration section in Elastic Beanstalk. I see scaling rules and a health check field there. Here is the environment behavior that I am looking for:

Scaling triggers
- Health check -- which is the [home page][1] (/index.php) -- returns a response status code within 4xx and 5xx
- spin up a new instance behind the Elastic Load Balancer which will handle web traffic
- in the meantime direct all traffic to the maintenance page
- If over a period of 3 minutes no instance is returning a health check response within 4xx and 5xx from the home page
- either scale down to two instances or keep the two "healthy" instances in rotation behind the ELB.

Will I need to use the tabs (monitoring and capacity) that I mentioned above? Can someone tell me set up the above environment triggers in AWS Elastic Beanstalk?


You can do basically all of what you want to do with the built in healthchecks of the AutoScaling Group (ASG) and Elastic Load Balancer (ELB) and Beanstalk creates.

  • By default when the ELB's healthchecks fail, traffic will stop being sent to that instance and be redirected to the other instances attached to that ELB, but there isn't any way to send customers to a maintenance page when all instances are unhealthy.
  • Any 4xx or 5xx will fail the healthchecks by default
  • If the ASG's healthcheck type is changed from EC2 to ELB, it will automatically replace instances that the ELB marks as unhealthy
  • The timers on the built in ELB healthchecks can be configured (how many consecutive requests must be missed, how long the timeout is, etc)

To do exactly what you want to do you would need to do a good bit of scripting to built your own healthcheck mechanism and actions. If what I described above works for you, all you need to do is change the healtcheck type on the ASG and (optionally) the timers on the ELB healthcheck

Since this is in beanstalk this will all need to be configured via EBExtensions (code snipits to change the infrastructure in the Beanstalk environment), since I don't believe any of these options are currently available in the Beanstalk console. Here's an example of the EBExtension to use for changing the healthcheck type of the ASG to ELB. https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environmentconfig-autoscaling-healthchecktype.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.