Comparison
Connection drainingvsGraceful shutdown
Connection draining
the instance is taken out of rotation but its open connections are allowed to finish, instead of being cut mid-response.
Stopping new connections to a backend being removed while letting existing ones complete, up to a timeout. It is the load balancer's half of a clean shutdown, and it must overlap with the workload's own grace period or requests are dropped in the gap. Long-lived connections — websockets, streaming, gRPC — are where a drain timeout tuned for short requests visibly fails.
Full entry →Graceful shutdown
on SIGTERM you stop accepting new requests, finish the ones in flight, and only then exit.
Ending a process in a way that does not drop work: deregister from the load balancer, stop accepting, complete in-flight requests, close connections, exit. Without it, every deploy sheds a burst of errors proportional to your request rate. The grace period must exceed your longest normal request, or the platform kills you mid-request anyway.
Full entry →