WSS
On this page
Deployment & DeliveryRequiredUpdated

Rollback strategies

A rollback strategy defines how a system reverts to a previous stable state after a failed deployment. Automated and tested rollbacks are essential for maintaining service level objectives.

Introduction

A rollback reverts an application to the exact version that was running before the most recent deployment. It is the primary emergency response mechanism for deployments that cause critical errors in production. The goal of a rollback is to minimize Mean Time to Recovery (MTTR) by restoring service stability as quickly as possible.

Mental Model

Think of a word processor’s “Undo” button. You type a new paragraph (the deployment). You realize the paragraph breaks the flow of the document (the error). Instead of manually deleting the words one by one while the reader waits (a forward fix), you press “Undo” (the rollback) to instantly restore the document to its prior, readable state.

Operational Pattern

The decision to rollback triggers either automatically via monitoring alerts or manually by an operator.

Once triggered, the deployment system locates the immutable artifact of the previous stable version. It provisions new instances running this artifact. The load balancer routes traffic to these restored instances and terminates the instances running the failed version.

In a blue-green deployment, the rollback is merely a routing change back to the idle environment. In a rolling update, the rollback is a new deployment process pushing the older artifact.

If a database schema changed during the failed deployment, the rollback process must also address the database state. This is often the most complex aspect of the operation.

Failure Modes

Database migrations block rollbacks. If a deployment drops a column from a table, rolling back the application code does not restore the deleted data. The old application code crashes because it expects the dropped column to exist.

Rollback procedures rot. If a team relies on forward fixes and rarely practices rollbacks, the rollback scripts or automation may fail during a real emergency due to configuration drift.

Missing artifacts prevent restoration. If the registry retention policy aggressively deletes old images, the system cannot fetch the previous version to restore it.

Security

Rollbacks can reintroduce known vulnerabilities. If a deployment patches a critical security flaw but introduces a functional bug, rolling back restores the functional system but leaves it vulnerable to exploitation. Operators must weigh the risk of downtime against the risk of compromise.

Rollback execution requires high privileges. An attacker who compromises the deployment system can force a rollback to a vulnerable version of the application.

Operational Guidance

Prefer automated rollbacks. Tie your deployment orchestrator to your monitoring system. If the error rate exceeds a predefined threshold within five minutes of a deployment, the system should trigger a rollback without human intervention.

Decouple database changes from application deployments. Structure database migrations to be backward-compatible. Add columns in one deployment, deploy the code that uses them in the next, and drop unused columns only after all active code versions no longer reference them. This ensures the application can safely rollback without requiring a simultaneous database restore.

Practice rollbacks in production. Schedule intentional rollback drills to verify that the automation works and that the team understands the procedure.

Diagnostics

Track the duration of a rollback. If restoring the previous version takes thirty minutes, the strategy fails to minimize MTTR effectively. Investigate caching or blue-green routing to accelerate the process.

Analyze the root cause of every rollback. A rollback mitigates the immediate impact, but the team must still determine why the flawed code passed the testing pipeline in the first place.

Related topics

Sources & further reading