Back to Hosting FAQs
HELP CENTER · FAQHosting1 min read

How should a hosted application shut down gracefully?

A graceful shutdown stops accepting new work, lets in-flight requests finish within a defined window, and then closes resources. Without this sequence, deployments or restarts can interrupt requests, duplicate jobs, or leave connections in uncertain states.

Hosting

Stop new work first

On a shutdown signal, mark the instance as not ready so traffic can drain, then stop accepting new requests or jobs. The exact order depends on the hosting platform’s signal and routing behavior; confirm what the platform actually sends.

Set a maximum drain period shorter than the platform’s forced termination window. If work may exceed it, persist progress or design the operation to resume safely rather than assuming the process will remain alive.

Close resources and verify behavior

After active work drains or reaches its deadline, close database pools, message consumers, and other resources using their supported shutdown methods. Ensure repeated signals and partial initialization are handled without hanging indefinitely.

Test a deployment or controlled restart under representative traffic. Measure interrupted requests, unfinished jobs, and shutdown duration, then tune readiness and timeout settings to match the observed platform behavior.

Back to Hosting FAQs