Question
Graceful Shutdown: In‑flight requests during zero‑downtime migration
Sora River
0 reputation · 08 Oct 2021, 15:44 UTC
30.6K views0
Goal
We need to migrate a small Ktor application without service interruption. The plan relies on Ktor’s Graceful Shutdown, which stops accepting new connections and waits for existing requests to finish.
Constraints
The default gracefulShutdownTimeout is 30 s, and any new request after shutdown begins receives a 503 Service Unavailable. Long‑running handlers may exceed the timeout, causing abrupt termination.
Unresolved Questions
- What is the exact behavior for requests that exceed the configured
gracefulShutdownTimeout—do they abort immediately or after the timeout? - Can we customize the response code for new connections during shutdown, or is 503 the only option?
- Is there a mechanism to guarantee that all in‑flight requests complete before the server fully stops, especially for non‑idempotent operations?