22 / 25 · Operations and recovery
Zero-downtime deployments
A zero-downtime deployment aims to release a change without interrupting required user operations. Rolling or blue-green rollout helps, but database compatibility, readiness and connection draining are part of the design.
Trace a rolling deployment that aims to keep four replicas available while a replacement starts. Check spare capacity, readiness, connection draining and database compatibility before releasing a new version.
What you will practise
- Trace a rollout
- budget extra capacity
- use expand/contract
Before you start: Readiness, old/new versions and schema compatibility.
About 4 minutes · offline-generated English female narration · captions included. Diagrams are conceptual; timings are illustrative.
Download MP4CaptionsListen without the video
Download audioChapters and full transcript
Let us understand zero-downtime deployments. A school repairs one classroom while students use another ready room. Moving students before the new room has desks causes disruption. Throwing away the old room key before every class moves makes rollback difficult. Old and new arrangements must coexist safely during the transition. A zero-downtime deployment aims to release a change without interrupting required user operations. Rolling or blue-green rollout helps, but database compatibility, readiness and connection draining are part of the design.
Follow the normal path. Visitors use the existing version while the next release is prepared. Establish user-visible metrics and rollback conditions before shifting traffic. Create new capacity without immediately removing all old instances. Download, initialization and dependency setup take time and need spare resources. SeatSpot must release a booking API while active users and old mobile clients remain. New code and old code may run simultaneously against the same data.
Now change one condition. The readiness gate verifies the instance can serve the intended request. A running process with missing dependencies should not receive normal traffic yet. A common misunderstanding is this: maxUnavailable: 0 guarantees the whole application is correct. It expresses a rollout constraint; readiness, data compatibility and spare capacity remain necessary. Think about this. Old code still reads a column while new code deploys. Can you drop that column immediately? Pause the video and make your prediction. No. Keep old/new versions compatible during coexistence and rollback. Remove obsolete structures only after the transition is proven safe.
Let us reason with a concrete example. Four replicas must remain available; one replacement is created before one old replica is removed. The rollout temporarily needs capacity for five. If no spare capacity exists, readiness and rollout policy can stall. This simple count excludes node limits and dependency capacity. Test old/new coexistence and rollback with real requests. Treat zero downtime as a measured release goal, not an unconditional Kubernetes flag. These figures are teaching examples, not production guarantees.
Turn the idea into a design decision. Send a bounded share to the new version and drain old work deliberately. Monitor errors and latency for real user operations, not only process health. Both versions can access the database during rollout. Expand and migrate safely before removing fields or behavior the old version still needs. When you try the practice task, look for this result. Rolling back code does not automatically reverse a destructive data migration.
Check your understanding. Stop or reverse traffic movement if the release violates its criteria. Code rollback cannot magically reverse incompatible or destructive data changes. Here is a challenge. Version B renames a database field and Version A still runs. What safer migration sequence can you use? Pause before the answer. Expand with the new field, implement compatible reads/writes, backfill and validate, switch traffic/readers, then contract only when old users are gone. Plan failure/rollback at each step. For an interview, discuss surge capacity, draining and compatible schemas. Say what you would measure, not only which tool you would buy.
Start with an everyday picture
A school repairs one classroom while students use another ready room. Moving students before the new room has desks causes disruption. Throwing away the old room key before every class moves makes rollback difficult. Old and new arrangements must coexist safely during the transition.
Why SeatSpot needs this
SeatSpot must release a booking API while active users and old mobile clients remain. New code and old code may run simultaneously against the same data.
Trace one step at a time
Move through the diagram at your pace. Teal paths are active; unavailable components are labelled.
Serve the old version
Visitors use the existing version while the next release is prepared. Establish user-visible metrics and rollback conditions before shifting traffic.
Read all six mechanism steps
Serve the old version
Visitors use the existing version while the next release is prepared. Establish user-visible metrics and rollback conditions before shifting traffic.
Start the replacement
Create new capacity without immediately removing all old instances. Download, initialization and dependency setup take time and need spare resources.
Check readiness
The readiness gate verifies the instance can serve the intended request. A running process with missing dependencies should not receive normal traffic yet.
Shift traffic gradually
Send a bounded share to the new version and drain old work deliberately. Monitor errors and latency for real user operations, not only process health.
Keep data compatible
Both versions can access the database during rollout. Expand and migrate safely before removing fields or behavior the old version still needs.
Validate rollback
Stop or reverse traffic movement if the release violates its criteria. Code rollback cannot magically reverse incompatible or destructive data changes.
Pause and make a prediction
Old code still reads a column while new code deploys. Can you drop that column immediately?
Correct a common misunderstanding
Claim to question: maxUnavailable: 0 guarantees the whole application is correct.
Better explanation: It expresses a rollout constraint; readiness, data compatibility and spare capacity remain necessary.
Stage an expand/contract rollout
- Add a compatible new field without removing the old one.
- Migrate/backfill, switch readers/writers and monitor.
- Remove the obsolete representation in a later verified release.
Check what you can explain
This is your self-check, not an automated grade. Try again without the diagram tomorrow.
0 of 3 goals checked. Choose one remaining idea to practise next.
Teach it back
Without looking, explain what this component changes, what it does not solve and what happens if it fails. Use the animation to check your explanation, then switch to Engineering.
Engineering model and trade-offs
Rolling deployment gradually replaces replicas; blue-green prepares a separate version then switches traffic; canaries expose a limited audience first. Each approach has different capacity and rollback requirements.
Readiness should mean the instance can serve intended traffic, not merely that its process started. Drain in-flight requests, close long-lived connections deliberately and allow graceful shutdown. Available spare capacity must cover the rollout.
Use expand/contract schema changes: introduce a compatible representation, migrate/backfill safely, switch readers/writers and only later remove old structures. Rolling back code does not undo an irreversible data migration.
Rolling deployment example: four replicas and one replacement
Four replicas must remain available; one replacement is created before one old replica is removed.
Reason with the numbers
The rollout temporarily needs capacity for five. If no spare capacity exists, readiness and rollout policy can stall. This simple count excludes node limits and dependency capacity.
Make a decision
Test old/new coexistence and rollback with real requests. Treat zero downtime as a measured release goal, not an unconditional Kubernetes flag.
Kubernetes rolling-update strategy
# Deployment strategy fragment
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0
maxSurge: 1
# Also define readiness and graceful termination.This fragment requires a complete Deployment and spare scheduling capacity. It does not guarantee database compatibility, successful probes or uninterrupted long-lived connections.
Where this is used
- Releasing user-facing services with an availability objective.
- Gradual validation and controlled rollback of compatible versions.
Common mistakes
- Marking a pod ready before initialization is complete.
- Dropping a database column still read by the old version.
- Assuming code rollback reverses data changes.
Practise a reasoned answer
Answer aloud or write notes before opening the reference. These prompts teach reasoning and trade-offs; they are not claimed questions from a particular company.
Why can rolling deployment still cause downtime?
Choose a practice depth
- Foundation
- Explain replacing one ready replica at a time.
- Practical
- Discuss surge capacity, draining and compatible schemas.
- Advanced
- Defend canary evidence, irreversible migrations, long-lived requests and rollback limits.
Self-check rubric
- State the required user outcome and the relevant invariant.
- Explain the normal path and one failure path.
- Name a cost or consistency/latency trade-off.
- Say what you would measure or test before trusting it.
For deeper practice, connect this topic to the previous lesson and identify a shared bottleneck. A longer answer is not automatically a better answer.
Try it before viewing the solution
Version B renames a database field and Version A still runs. What safer migration sequence can you use?
Check one key idea
Your explanation and interview notes
Saved only in this browser when storage is available. Export a backup from the course page before clearing browser data or moving devices.
Loading your local notes…
Official references and next reading
The explanation, fictional examples and animations are original teaching material. Vendor behavior depends on the specific product/version; use its documentation before deploying.