Systems & Backend

Graceful Shutdown

Draining in-flight work and closing connections cleanly before a process exits, so a deploy drops no requests.

A graceful shutdown is when a process, told to stop, first stops accepting new work, finishes the requests already in flight, closes connections cleanly, and only then exits — instead of dying instantly and dropping active requests.

Worked example: on a rolling deploy an instance receives SIGTERM, deregisters from the load balancer, waits for its in-flight requests to complete (up to a timeout), then exits — users never see a dropped connection. Gotcha: it requires cooperation across layers — the orchestrator must send SIGTERM and wait a grace period before SIGKILL, the app must handle the signal, and the load balancer must stop routing first (connection draining) — miss any link and deploys cause errors.