Measuring dropped requests during a deploy with a simple load loop
"Zero downtime" is easy to claim and easy to measure. Before trusting any deploy setup, run a load loop against it during a real deploy and count the failures.
The loop
end=$((SECONDS+120)); ok=0; bad=0
while [ $SECONDS -lt $end ]; do
code=$(curl -s -o /dev/null -w '%{http_code}' -m 5 https://app.example.com/healthz)
if [ "$code" = "200" ]; then ok=$((ok+1)); else bad=$((bad+1)); echo "$(date +%T) $code"; fi
sleep 0.2
done
echo "ok=$ok bad=$bad"
Start it, trigger a deploy, and read the output. Every non-200 line has a timestamp, so you can line it up with the deploy log.
Test a real page too
Health endpoints are cheap. Add a second loop against a page that touches the database, because failures often come from connection pools that are not ready yet.
Use a load tool for concurrency
A single curl loop sends one request at a time. Tools like hey or k6 send many in parallel and catch errors that only appear under load, such as the old container refusing new connections while it drains:
hey -z 120s -c 20 https://app.example.com/
What the results usually show
- A burst of 502s: the proxy switched before the new container was listening. Add or fix the health check.
- Connection resets at the end: the old container was killed instead of drained. Handle
SIGTERMand set a stop timeout. - A few 500s: a migration ran before the old code stopped. Make migrations backward compatible.
Keep it in CI
Run the loop against staging on every deploy and fail the pipeline if bad is above zero.
A longer guide to zero-downtime deployments on a VPS covers the setups that pass this test. I work on Peon, an open-source self-hosted deployment platform.