Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make an EC2 instance automatically reboot when ELB says it's unavailable?

Every now and then Elastic Load Balancer (ELB) kicks out one of my servers for being unavailable. Which is good -- hardly any interruption.

Usually, just rebooting the instance through the AWS Console fixes the problem.

I would like to have my EC2 instance automatically reboot when it becomes unavailable.

What's the best way to do this? (it happens to be a Windows instance, but ideally that shouldn't matter)

like image 256
pk1557 Avatar asked Mar 05 '12 23:03

pk1557


People also ask

What happens when an Amazon EC2 instance fails the Amazon ELB health check?

If an instance fails these status checks, it is marked unhealthy and is terminated while Amazon EC2 Auto Scaling launches a new replacement instance. You can attach one or more load balancer target groups, one or more Classic Load Balancers, or both to your Auto Scaling group.

Why instance is out of service in load balancer?

An instance might fail the ELB health check because an application running on the instance has issues that cause the load balancer to consider the instance out of service.


1 Answers

I got a cheap EC2 micro instance and wrote a simple script that lists all my servers on EC2, and does a GET on each one to make sure that it's functioning properly. If a server isn't functioning properly, my script reboots it. I have the script running once every 10 minutes.

Woulda been slightly easier if there were a service out there to do this for me, but the system was easy to set up and the micro instance is cheap.

like image 111
pk1557 Avatar answered Oct 04 '22 03:10

pk1557