I have a service that I want to run on preemptible instances on Google Cloud Platform. The instances will live behind a load balancer. Most requests take < 10 seconds to handle.
I can't modify the service itself, but there is an nginx instance on the same image that sits in front of the service that I can configure.
As far as I can see an ACPI soft shutdown signal is sent to the instance 30 seconds before it's shut down, at which point I'd like it to stop receiving requests.
I could create a shutdown script that reconfigures nginx to stop forwarding health checks to the service, and instead respond with a thumbs down itself, but this seems a bit hacky and I feel like there should be a better way. (It also feels a bit wrong to say the service is not healthy – it just wants to be taken out of the pool.)
What would be the appropriate way of telling the load balancer to stop sending requests to this instance, so it can (hopefully) fulfil its current requests and then shut down without having received any new requests in the meantime?
┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │
┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │
Preemptible instance │ │
│ │
│ │
│ │
│ │
┌─────────┐ │ ┌─────────┐ ┌─────────┐ │
│ Load │ │ │ /health │ some │ │ │
────▶│balancer │──────┼──▶│ nginx │──────────▶│ service │ │
│ │ │ │ /api/… │ │ │ │
└─────────┘ │ └─────────┘ └─────────┘ │
│ │
│ │
│ │
│ │─
│─
└ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─