- Health Checks - Ensure new instances are ready before receiving traffic
- Graceful Shutdown - Allow old instances to finish processing before termination
Health Checks
Health checks indicate whether an application is healthy and ready to receive traffic. When enabled, traffic won’t switch from the old application instance until the health check confirms the new instance is ready. Health checks can be configured in the Advanced tab of your service settings.Readiness probes should be used in conjunction with graceful shutdown behavior
to control exactly when applications stop receiving traffic. See the graceful
shutdown section for more information.
Web Services
For Web services, configure HTTP-based health checks where your application returns:200status code when ready to receive traffic500-level error code when not ready

/healthz as your health check endpoint, no traffic will be routed to the web service until that endpoint returns a 200 status code.
Workers
For Worker services, you must set up health checks using custom commands or scripts instead of HTTP endpoints. This is useful for monitoring services like Celery workers that don’t expose HTTP endpoints. To configure command-based health checks, create a health check script that:- Executes the necessary commands to check your worker’s health
- Returns exit code
0if the worker is healthy - Returns a non-zero exit code if the worker is unhealthy
Worker services only support command-based health checks. HTTP health checks are only available for Web services.
Graceful Shutdown
When applications are being re-deployed, old instances receive aSIGTERM termination signal. They are then given a Termination Grace Period—the number of seconds before the application is forcefully killed.
During this period, your application should:
- Stop accepting new work
- Complete or close existing connections
- Exit gracefully
Web Services
Web services keep receiving traffic until they are taken out of the routing, which does not happen the moment they start shutting down. The recommended graceful shutdown sequence is:- When
SIGTERMis received, immediately return a500-level response on your health check endpoint to mark the instance as unavailable. - Keep accepting new requests for a short drain window while routing catches up (see below), and start draining the connections you already hold.
- Close the server to prevent additional connections once the drain window has passed.
- Drain all existing connections before the grace period ends, then exit gracefully.
Why traffic keeps arriving after SIGTERM
When an instance is replaced, the orchestrator starts two things at around the same time: it sendsSIGTERM to your process, and it begins taking the instance out of the routing. Neither one waits on the other, and neither one waits on your health check. Your 500-level response marks the instance as unavailable, but it is not the switch that stops traffic.
Removal from the routing takes effect only once the router picks up the change, at least 1 to 5 seconds later. Every request dispatched before that still arrives at the instance, including requests sent after your process has already received SIGTERM.
Size your drain window to cover that gap. A window of 5 to 15 seconds is a reasonable starting point, and the termination grace period must be longer than the drain window plus your slowest request.
For the underlying mechanics, see step 3 of Pod termination flow in the Kubernetes documentation.
Workers
For Worker services, implement graceful shutdown using signal handling and file-based coordination:- Trap the SIGTERM signal in your worker process or an init script for the service.
- Write a shutdown marker to a file when the signal is received, indicating the worker should stop.
- Adapt your health check script to check for this shutdown marker:
- If the marker indicates shutdown is in progress, the script should return a non-zero exit code.
- This signals to Porter that the worker is no longer healthy and should not receive new work.
High Availability
To ensure your applications are fault tolerant and resilient against failures, configure at least 3 instances for production workloads. This can be set in the Resources tab.If you are using autoscaling, set the minimum replicas to at least 3.

