Software Design

Graceful Microservice Shutdown and Drain Flow

UML Sequence Diagrams · made in Skemio

Sequence diagram illustrating graceful shutdown steps between Kubelet, Service Registry, API Gateway, and Application instance.
Sequence diagram illustrating graceful shutdown steps between Kubelet, Service Registry, API Gateway, and Application instance.

What it shows

  • Deregister from discovery first so new requests are routed elsewhere.
  • Allow a brief sleep window for in-flight traffic routing convergence.
  • Drain existing connections and flush buffers before terminating the process.

The takeaway

Deregister before disconnecting: never kill a pod while load balancers still send traffic.

More uml sequence diagrams