0

I have a single ubuntu ec2 instance running nginx behind an ELB. Occasionally the instance runs out of memory which crashes the node app behind nginx and then I get a 502 bad gateway message and have to reboot.

I can see how to get alarm messages that this has happened, and can set the ELB health check to fail if there is a 502, but is it possible to have the instance reboot automatically?

In the EC2 dashboard I see where I can tell it to reboot if the Instance Status Check fails, but I don't think this can be configured to do what I want - the ELB health check is not the same as the Instance Health Check. It seems like somehow I need to connect the two.

I am not using auto scaling.

Ron
  • 101
  • 3
  • 2
    Is there are specific reason you are not using autoscaling? Even if you were using an ASG of size 1 (for just one instance), you could get the benefit of [autoscaling health checks](http://docs.aws.amazon.com/autoscaling/latest/userguide/healthcheck.html), which would do what you want. – Castaglia Dec 29 '16 at 22:11
  • I just haven't learned that side of it yet and was hoping for a way to do it without it. – Ron Dec 29 '16 at 22:37

1 Answers1

0

You could write a Lambda that listens to the SNS topic of the alarm and initiates a reboot of the affected instancee.

Jason Martin
  • 5,023
  • 17
  • 24