1

Recently I was playing around a bit with AWS as a part of a course that I am doing. I came across a situation that to be honest is keeping be in vilo.

I made a web application which connects to a backend that basically launches a EC2 t2.micro instance on AWS. From time to time, I pull the status of the machine to check whether it is on running state or note. The AMI I am using it is a configured wordpress from the marketplace.

As soon as the instance gets to the running state, I show a message indicating the server is up and running and provide the user with the instance's public ip address, the problem is that, it is not after a few minutes later when indeed the IP is resolved/accessible. The security group attached to the instance has the inbound and outbound traffic configured to allow TCP traffic on port 80, 22 and 443.

My question is, the running state simply means the instance is ready to work but, as far as I know, it does not mean OS has booted nor the X application (in this case wordpress and its configured server) are ready to or finished the bootstrapping. How can I check that indeed the application/OS has booted is I can ensure that when the user is trying to access the IP it will not timeout.

My first attempt was to ping the instance bu to be honest I don't think it's a reliable request since, I'd also need to enable the ICMP protocol but at the end, it's working in another internet layer.

1 Answer 1

0

What you are talking about is known as a health check. Typically these are handled by load balancers, to decide whether instances are "healthy", and thus can serve (usually HTTP) traffic. The load balancers will poll and endpoint that you define to decide whether the instances are healthy, usually by seeing if the HTTP response code is some known-good one, like 200.

One solution therefore, could be to front your application with a load balancer, and enable health checks on the relevant urls. This will check whether your application is serving traffic properly, when polled by the load balancer. While this adds a level of complexity (and cost) to the app, it is also quite easy to do.

Of course, you could mimic this functionality without an AWS load balancer, by having your app poll the url that the app is supposed to respond on, by using the DNS or IP name returned by AWS after the instance becomes "running".

Another option would be to set up an actual monitoring system to check whether the application is serving content. A very simple and free tool that would do the job is e.g. Freshping.

You could also write an Inspec Compliance profile to describe a known good state of the machine. Inspec can connect to the machine via SSH, which you specify as being open. This may sound like overkill, and quite similar to the ICMP test you considered before, but it's nevertheless an option :)

1
  • Thanks Bruce, that was exactly what I was looking for! Commented Dec 8, 2019 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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