Module 12 · Project 12 · Ship with Zero Downtime · Lesson 41 of 48
Build it: releases nobody notices
The details that make zero downtime real: graceful shutdown, backwards-compatible database changes and feature flags. Then build it and test yourself.
In this lesson · about 40 minutes
- Make Pods shut down gracefully
- Change a database schema with expand and contract
- Separate deploying code from releasing a feature
Graceful shutdown
Even with a perfect strategy, users see errors if Pods die mid-request. When Kubernetes stops a Pod, it sends SIGTERM, waits terminationGracePeriodSeconds (default 30), then kills it. Your app should:
- On SIGTERM, start failing its readiness probe so no new requests arrive.
- Finish the requests already in flight.
- Close database connections and exit.
Because the Service and load balancer take a few seconds to notice, many teams add a short preStop sleep (5–10 s) before the app begins shutting down.
The database: expand and contract
During any of these strategies, v1 and v2 run at the same time against the same database. So a schema change must work with both. Renaming a column in one step breaks v1 instantly. Instead, use expand and contract:
- Expand: add the new column (
full_name) and keep the old one. Deploy code that writes both and reads the new one, falling back to the old. - Migrate: backfill old rows in small batches.
- Switch: deploy code that only uses the new column.
- Contract: one release later, once nothing reads it, drop the old column.
Every step can be rolled back on its own. Slower, but no step can break the running version.
Feature flags
A feature flag is an if-statement you can switch at runtime: if (flags.enabled("new-export", user)) { … }. You can then deploy code with the feature off, and release it later, to staff first, then 10% of users, then everyone. If it misbehaves, switch it off in seconds, without a deploy. Tools: OpenFeature with a provider, LaunchDarkly, Unleash, or a simple config table. Remove old flags once they're fully on, or they pile up.
Build it in stages
- Rolling: set
maxSurge: 1, maxUnavailable: 0, readiness probes, SIGTERM handling and a preStop sleep. Run a load test (k6) during a rollout: target 0 failed requests. - Canary: install Argo Rollouts, convert the Deployment to a Rollout with 5/25/50/100 steps and a Prometheus error-rate analysis.
- Prove it: release a version that returns 500 on 30% of requests. The analysis should abort it automatically. Record the timeline.
- Blue-green: try the blueGreen strategy on staging with a preview Service for smoke tests.
- Database: rename a column with expand and contract across three releases, with the load test running.
- Flag: put a new feature behind a flag and release it to 10% of users.
Guided dialogue
Mock interview: zero-downtime releases
0 of 3 answered
Three common questions.
Rolling, blue-green or canary: how do you choose?
Flashcards
Project 12 flashcards
0 of 6 known
Say the answer out loud, flip the card, then be honest: cards you miss come back at the end.
Practice exam
Project 12 practice test
Eight questions, 10 minutes.
- 8 questions · 10 minutes
- No feedback until you submit. Flag questions to come back to them.
- Aim for 85% or better before you move on. The real exam's 750 out of 900 is roughly 80–83%.
Write the 'Releases' section for your project.
Consider these questions and write down your thoughts. What you write stays on this device.
Written by Noviq Academy in its own words. The labs are simulations: no real servers are touched. When you build the projects yourself, use a practice virtual machine or a free-tier cloud account you control, watch your cloud spending, and never run cleanup or delete commands on a machine you care about. Tool names belong to their owners; versions and output are shown for learning and may differ slightly from yours. Read-aloud and the whiteboard voice use your device's built-in voices.