1

we're using Google Cloud Platform, and running an instance Ubuntu which has Apache listening on port 80.

Sometimes the instance stops responding, and the server goes down in Cloudflare (but that's not the case).

We need a solution, something to check time to time, a routine, that reset/restart the instance if stops responding on port 80.

Maybe a Shell Script? Maybe something inside Cloud Platform which I haven't noticed?

I've searched all over, sorry if this is repeat, thanks for any kind of help.

Yannick MG
  • 178
  • 5

3 Answers3

1

Creating a health check that listens to port 80 would do your job but a health check alone wouldn't work. You will have to:

  1. Create a load balancer to a managed instance group
  2. That managed instance group should have autoscaling turned off such that only your instance is the only one in the group.
  3. Then you can point Cloudflare to the frontend IP that you created(in case you opted for a static IP)/got while creating the load balancer.

This way every time your health check fails, your instance would restart. Make sure you configure proper firewall rules for the health check to work.

The other thing you can do is configure a Stackdriver Monitoring metric and write a program that uses the Stackdriver Monitoring API, such that a web hook will further take some action like notify someone or maybe even restart the system using some kind of a configuration management tool.

Even though bash is also a good option, the GCP console gives you an interactive interface to change the specifications at any time you wish. You don't have to get in the hassle of rewriting your scripts again in case your use case changes and you want to monitor more of that instance.

Pranay Nanda
  • 151
  • 6
0

I'd start with a monitoring system like nagios so you can have some idea what is happening. Then have someone manually restart it until you see patterns worth automating. You can hook nagios up to PagerDuty to make sure someone gets notified.

Beyond your internal monitoring it might be good to have an external service like hund.io or pingdom keep an eye on your site.

chicks
  • 3,793
  • 10
  • 27
  • 36
0

To monitor periodic health of your instance you can create a health check which will send periodic probes on a specific port to check VMs health. The health check will not restart your instance if it is unhealthy. To recreate unhealthy instance you can create a managed instance group and put your instance into the group and create health check. Find the document for managed instance group here The managed instance group comes with a feature called autohealing which recreates the unhealthy instances.You can see the document here

shamma
  • 99
  • 3