Start here. This is the direct spoken answer to practice first.
Overview
Coordinates readiness, signals, request drain, lifespan cleanup, and a bounded termination deadline.
During deployment the instance should stop receiving new traffic, receive the server's termination signal, and allow active requests to finish within a grace period. FastAPI lifespan cleanup then closes process-owned clients and flushes bounded telemetry. The container command must let the Python server receive signals directly or forward them correctly. After the deadline, remaining work may be terminated, so handlers cannot assume unlimited shutdown time.