Menu

Django in Production #18: Zero-Downtime Deploys — Blue-Green/Rolling, Migration Order and Restarts
📰

Django in Production #18: Zero-Downtime Deploys — Blue-Green/Rolling, Migration Order and Restarts

DEV Community: django·Linh Fish Dev·about 2 hours ago
#2bYsWaGm
#devtodjango#devto#dev#deploy#code
Reading 0:00
15s threshold

Episode 17 built the CI/CD pipeline: push code to main, tests run, then the deploy goes to the server automatically. But an automatic deploy isn’t necessarily a zero-downtime one — restart the app while a user is entering an expense and their request fails with a 502. This episode finishes the last step: shipping the new version without users noticing, and rolling back in seconds.

Why Stop-and-Restart Deploys Cause Downtime

The simplest deploy is: stop the service, pull the new code, run migrations, then start again. In the gap between stopping and the new app being ready, every request fails — with Gunicorn, usually 5–30 seconds. A zero-downtime deploy removes that gap by always keeping at least one version of the app running.

The Golden Rule: Migrations First, Code Second

The correct order for every deploy is: pull the new code, run migrations, then restart the app.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.