Rollbacks
Fast revert paths for bad prompts, models, or deployments.
In plain words
A rollback means quickly switching back to the last version that worked when a new one causes problems.
Think of it like…
An undo button and a spare tyre: you don't plan to use them, but when you hit a pothole you want to be back on the road in minutes, not stranded while you debug the road.
Where you’ve seen it
A bad prompt reaches 100% of traffic (4,167 requests an hour, 69.4 a minute). Timeline A (with rollback): detection by the quality alert and error spike takes 5 minutes, the decision 5 minutes and moving the production prompt label back 2 minutes: 12 minutes of exposure, about 833 affected requests. Timeline B (fix-forward): diagnosing, patching, testing and deploying takes 90 minutes: about 6,250 affected requests, 7.5 times as many. The rollback toolbox and typical speeds: prompt label or feature flag: seconds; model snapshot config: seconds to a few minutes (rolling restart); container image: kubectl rollout undo in 2 to 5 minutes; retrieval index: switch the alias from docs_v8 back to docs_v7 in seconds because the old index was kept; database migration: not rolled back (migrations use expand/contract so the old code keeps working). Side effects are handled explicitly: semantic-cache entries are keyed by prompt version, so entries from the bad version are purged by key; queued jobs created by the bad version are paused and re-run; users who received bad answers are identified from traces by version and notified where needed. The team rehearses rollbacks in staging monthly, keeps the previous three artefacts of each type warm and automates rollback when a canary guardrail breaches.
Words you’ll hear
- MTTR
- Mean time to restore service after a failure.
- Fix-forward
- Resolving a bad release by shipping a new fix instead of reverting.
- Expand/contract migration
- Changing schemas in compatible steps so code can roll back safely.
- Blast radius
- How many users or requests a failure affects, which grows with time to rollback.
Visual diagram
Theory & deep dive
Designing for fast, safe rollback
Make every change revertible by design. Immutable, versioned artefacts (images by SHA, prompts by version, models by snapshot, indexes by version with an alias) mean rollback is a pointer change, not a rebuild. Decouple deploy from release with feature flags and labels so the new behaviour can be switched off without redeploying. Keep the previous N versions available and warm (the old index loaded, the old model endpoint configured) so reverting doesn't depend on rebuilding under pressure. For databases use expand/contract migrations: add new columns or tables first (compatible with old and new code), switch code, then remove old structures in a later release; avoid destructive migrations in the same release as the code that needs them, because data can't be un-dropped.
Plan the rollback decision: define triggers up front (error rate above X, safety flag increase, cost +15%, judge score −3 points) and who may pull the trigger; prefer automatic rollback for canary guardrail breaches and a single documented command or button otherwise. Culture matters: treat rollback as the normal first response, not an admission of failure, and investigate once service is restored. Quantify the benefit: at 69.4 requests a minute, a 12-minute rollback exposes about 833 requests versus 6,250 for a 90-minute fix-forward.
Detect 5 + decide 5 + rollback 2 = 12 min × 69.4 req/min ≈ 833 requests. Fix-forward 90 min × 69.4 ≈ 6,250 requests. A prompt-label rollback that takes seconds instead of minutes would trim exposure further to roughly 700 requests, limited mostly by detection time.
Side effects, stateful systems and practice
Reverting code doesn't undo what the bad version already did. Caches: include the prompt, model or config version in cache keys (semantic and response caches), then purge entries written by the bad version after rollback. Queues and jobs: jobs enqueued or processed by the bad version may carry bad results or payload formats; pause consumers, drain or re-run affected jobs and make handlers tolerate both formats. Data written: records created from bad outputs (wrong classifications, summaries, embeddings, refunds) need identification by version in traces and a repair or reprocessing plan; emails or notifications already sent may need follow-up. Vector indexes and embeddings: keep the old index and embedding model available and switch via alias; re-embedding in place makes rollback hard. Fine-tuned or learned state (feedback loops, memory) can absorb bad behaviour, so isolate writes by version where possible.
Practice and verify: rehearse rollbacks in staging on a schedule (a rollback you've never run may not work), include them in release checklists and game days, measure time to rollback as a KPI and keep a runbook with exact commands and owners. Automate: Argo Rollouts, Flagger and feature-flag platforms can revert on metric breaches; prompt registries move labels in one call. After the incident, write a short post-incident review: what detected it, how long each phase took, what the blast radius was and which guardrail or test would have caught it earlier, then add that test to the eval gates and canary guardrails. Be careful with rollbacks that conflict with security fixes (don't revert a patch that closes a vulnerability: roll forward with a mitigation) and with irreversible data changes.
Semantic cache keys are (tenant, language, prompt_version, hash). After moving the label from v15.1 back to v14.2, a job deletes entries with prompt_version = 15.1.0 (12,400 entries). Without version-scoped keys, bad answers would keep being served from cache for hours.
How it works, step by step
Step 1 of 41. Make changes revertible
Use immutable versioned artefacts, flags and labels, alias-based indexes and expand/contract migrations.
- Keep
- 3 previous versions warm
When to use it & trade-offs
What it is
A rollback reverts a system to a previous known-good state after a bad change. In AI products the revertible things are many: a deployment (previous container image), a prompt version (move a label back), a model (point config at the earlier snapshot), a feature flag (switch off), a retrieval index or embedding model (switch an alias to the old index) and configuration. Rollbacks differ in speed (a flag or label flip takes seconds, an image rollout minutes), in safety (code can be reverted, data written by the bad version cannot always be) and in side effects (caches, queues and partial writes may hold bad outputs). A good rollback is fast, rehearsed, automatic where possible and part of how every release is designed.
Why it matters: Mean time to restore (MTTR) usually matters more than preventing every defect: a 12-minute rollback limits damage far better than a 90-minute fix-forward under pressure. AI changes are especially risky because quality regressions are subtle and non-deterministic, and they often surface only in live traffic. Teams that can revert a prompt or model in seconds can afford to ship more often; teams without a rollback path hesitate, batch changes and make riskier releases.
When to reach for it
- Bad prompt, model or retrieval releases
- Failed deployments and configuration errors
- Canary guardrail breaches
When to avoid or be careful
- Releases with no rollback path
- Destructive database changes shipped with the code that needs them
- Rebuilding old versions from scratch during an incident
Recovery strategies
Strengths: Fast and predictable; limits blast radius.
Watch out: Needs revertible artefacts; side effects remain.
Strengths: Moves the system ahead.
Watch out: Slower and riskier under pressure.
Strengths: Seconds; targeted.
Watch out: Only works if the change was flagged.
Interview signals & numbers to know
When this topic comes up
- “How fast can we revert?”
- MTTR
- Expand/contract migrations
- Version-keyed caches
- Automatic rollback
Benchmarks & rules of thumb
- 12 min vs 90 min
- rollback versus fix-forward time
- 833 vs 6,250
- affected requests at 69.4 requests a minute
- seconds
- time to move a prompt label or flip a flag
Common mistakes & follow-ups
Common interview mistakes
- Keeping only the latest artefact, so there's nothing to roll back to.
- Forgetting that caches keep serving the bad version's outputs.
- Never rehearsing the rollback procedure.
Likely interviewer follow-ups
- How would you roll back a bad prompt release?
- Why are expand/contract migrations important for rollbacks?
- What side effects must you clean up after a rollback?
Knowledge check
Put it into practice
Practice related interview Q&A
Apply Rollbacks with generative AI interview Q&A and hands-on practice.