every compose deploy drops about 40 seconds of requests, how do people avoid this Zero Downtime
Single VPS, docker compose, caddy in front. Deploy is git pull && docker compose build && docker compose up -d. Compose stops the old api container, starts the new one, and for roughly 30-45 seconds caddy returns 502 while the new one boots.
It's an internal tool so nobody has complained, but I deploy three or four times a day and I'd like to stop flinching. I don't want kubernetes and I don't want to move to a platform. What's the minimum thing that takes me from 40 seconds of 502 to zero?
@coworking_cass · 2mo ago · 3 replies
Minimum viable is healthcheck plus a second replica plus letting caddy route around the unhealthy one.
Then
docker compose up -d --wait, and caddy load-balancing over both with a health check on/healthz. It pulls an unhealthy backend out of rotation instead of 502ing at it.That gets you most of the way, but compose will still cycle both replicas at once unless you push them one at a time. For true rolling on plain compose the honest answer is you script it: start new, wait for healthy, drain old, stop old. It's about 30 lines of bash and it works fine.
The other honest answer is that this is exactly what Kamal does, and Kamal is not kubernetes. Single VPS, compose-shaped config, does the health-check-and-swap for you.
Reply
Report
@negativesplitz · 2mo ago
--waiton its own took me from 40s to about 12, which is already a different experience. Looking at kamal for the rest.Reply
Report
@mulch_mule · 2mo ago
Worth adding that
start_periodmatters a lot here. Without it, healthcheck failures during boot count as retries and the container gets marked unhealthy before it ever finished starting.Reply
Report