The user wants a comprehensive deployment runbook specifically designed with a "rollback-first" philosophy.
This means the primary action when things go wrong is to revert, not to troubleshoot and fix forward.
The deliverables requested are:
- Signals: What metrics/logs indicate a failure?
- Decision Tree: A flowchart/logic path for action.
- Ownership Matrix (RACI): Who does what.
- Communication Templates: Scripts for Slack/Email/Status pages.
Step 1: Philosophy & Context (The "Why")
- Why rollback-first? Minimize MTTR (Mean Time To Recovery). Fixing forward takes longer and is riskier under pressure.
- Context: This needs to be generic enough to apply to most web services but specific enough to be useful.
Step 2: Signals (The Triggers)
- Need distinct categories: Technical (Latency, Errors), Business (Conversion, Revenue), and Infrastructure (CPU, Memory).
- Key signals:
- Error rates (5xx, 4xx spikes).
- Latency (P99 exceeding baseline).
- Dependency health (DB connection pool exhaustion).
- Business logic (failed checkouts, login failures).
- Thresholds: Need to define "Hard" triggers (auto-rollback) vs. "Soft" triggers (human investigation).
Step 3: Decision Tree (The Process)
- Start: Deployment initiated.
- Step 1: Monitor Canary/New Version.
- Step 2: Signal received?
- No -> Continue/Succeed.
- Yes -> Assess severity.
- Step 3: Is it a critical threshold breach?
- Yes -> EXECUTE ROLLBACK immediately.
- No -> Investigation window (e.g., 15 mins).
- Step 4: Root cause obvious and fixable in 15 mins?
- Yes -> Fix forward (with caution).
- No -> EXECUTE ROLLBACK.
- Step 5: Post-rollback actions (Root Cause Analysis).
Step 4: Ownership Matrix (RACI)
- Roles:
- Release Captain (The deployer).
- On-Call/SRE (The infrastructure watcher).
- Product Owner/Dev Lead (Business logic owner).
- Stakeholders (Executives/Customers).
- Actions:
- Monitoring, Decision to Rollback, Execution, Communication, RCA.
Step 5: Communication Templates
- Need different phases:
-
- Pre-Deployment (Heads up).
-
- Monitoring/Issue Detected (Alert).
-
- Rollback Decision (The Action).
-
- All Clear (Resolution).
- Channels: Internal (Slack), External (Status Page).
Step 6: Structuring the Document
- I need to organize this clearly with headers, bullet points, and code blocks for templates.
- I should include a "Golden Rule" section to emphasize the mindset.
Refining the Content:
- Self-Correction during drafting: Make sure I emphasize that "Rollback First" means we don't debug in production. We rollback, then debug in staging.
- Visualizing the Decision Tree: Since I can't draw a chart, I'll use a Mermaid-style code block or a structured text-based flow.
Drafting the Components:
- Signals: Specific metrics are better than vague ones. "HTTP 500 > 1%" is good.
- Decision Tree: Keep it binary. Yes/No paths.
- RACI: Ensure the "Accountable" person is clearly defined. Usually the Release Captain.
- Templates: Use placeholders like
[Service Name] and [Time].
Final Polish:
- Tone: Professional, operational, urgent but calm.
- Format: Markdown.
Let's assemble the runbook.
This runbook establishes a Rollback-First methodology. The core philosophy is: If a deployment triggers a severity threshold, we do not troubleshoot in production. We revert traffic and troubleshoot in safety.
Runbook: Rollback-First Deployment Strategy
Version: 1.0
Scope: Critical Production Deployments
Golden Rule: MTTR (Mean Time To Recovery) > MTTF (Mean Time To Failure). A failed deployment takes 2 minutes to roll back but hours to debug. Always choose the 2-minute path.
1. The Signal Matrix (Triggers)
Do not roll back based on "gut feeling." Roll back based on objective data signals collected during the "Golden Window" (the first 15 minutes post-deployment).
Critical Signals (Immediate Rollback)
If any of these thresholds are breached, the decision is automatic. No human judgment required.
| Signal Type | Metric | Threshold |
|---|
| Availability | HTTP 5xx Rate | > 0.5% of total traffic |
| Availability | Health Checks | Failing in >1 AZ/Region |
| Latency | p95 Latency | > 2x Baseline (e.g., Baseline 200ms -> Spike to 400ms) |
| Dependency | DB/Cache Errors | Connection pool exhaustion or auth failures |
| Business | Conversion/Orders | Zero transactions for > 2 mins (during peak) |
Warning Signals (Hold & Assess)
If these occur, freeze the rollout and wait 5 minutes. If they persist, roll back.
| Signal Type | Metric | Threshold |
|---|
| Latency | p99 Latency | > 1.5x Baseline |
| Saturation | CPU/Memory | Sustained > 85% utilization |
| Errors | HTTP 4xx Rate | Significant unexplained spike (excludes 404s) |
| Logs | New Exception | Appearance of a "Unknown" or "Fatal" log signature |
2. The Decision Tree
This flowchart governs the "Golden Window" (T+0 to T+15 mins).
graph TD
A[Start Deployment] --> B{All Pods Healthy?}
B -- No --> C[EXECUTE ROLLBACK]
B -- Yes --> D[Shift Traffic to New Version]
D --> E{T+5 mins: Golden Window}
E --> F{Critical Signals Breached?}
F -- Yes --> C
F -- No --> G{Warning Signals Present?}
G -- Yes --> H[Extend Monitoring Window]
H --> F
G -- No --> I[Deployment Successful]
C --> J[Post-Mortem & Fix in Staging]
J --> A
Operational Logic:
- The "Stop" Button: If the automated CI/CD pipeline detects a health check failure, it auto-reverts.
- The Human Element: If a human observes the dashboard and sees a Critical Signal, they execute the manual rollback command immediately. They do not check logs first.
3. Ownership Matrix (RACI)
To prevent "too many cooks" during an incident, roles are strictly defined.
| Role | Responsibilities | Accountable (A) | Responsible (R) | Consulted (C) | Informed (I) |
|---|
| Release Captain | Executes commands. Owns the Go/No-Go decision. | X | X | | |
| SRE / Ops | Monitors dashboards. Validates infrastructure. | | X | | |
| Service Owner | Validates business logic (e.g., 'Can users login?'). | | X | X | |
| Incident Commander | (Only if incident declared) Coordinates comms. | X | | | X |
| Stakeholders | Business owners waiting for the feature. | | | | X |
The Rule of Two: Ideally, only two people are on the "hot mic" during deployment: The Release Captain (executing) and the Service Owner (watching business metrics).
4. Communication Templates
Clear communication prevents panic. Use these templates in Slack/PagerDuty/Email.
Phase 1: Pre-Deployment (Heads Up)
Channel: #engineering-deploys
Owner: Release Captain
[STARTING DEPLOYMENT]
Service: [Service Name]
Version: [Git Hash/Tag]
Captain: @username
Rollback Plan: kubectl rollout undo deployment/[name] (or re-run previous TF apply)
ETA: 10 minutes.
:rotating_light: Expectancy: Brief blip in logs is normal. Do not page unless alert persists > 3 mins.
Phase 2: Rollback Triggered (Incident Start)
Channel: #engineering-deploys & #general
Owner: Release Captain
[ROLLBACK INITIATED]
Service: [Service Name]
Reason: Elevated 5xx errors detected (1.2% threshold breached)
Action: Executing rollback to version [Previous Version].
:stopwatch: ETA to restoration: 2 minutes.
Do Not Disturb: Engineering is focused on stabilization.
Phase 3: Rollback Complete (All Clear)
Channel: #engineering-deploys
Owner: Release Captain
[ROLLBACK COMPLETE]
Service: [Service Name]
Status: Traffic is now serving [Previous Stable Version].
Metrics: Error rates returning to baseline.
Next Steps:
- Captains are analyzing logs offline.
- Incident Report (Post-Mortem) will be scheduled for tomorrow.
- No immediate re-deploy attempt will be made today.
Phase 4: External / Stakeholder Update
Channel: Email / Status Page
Owner: Incident Commander
Subject: Update regarding [Service Name] availability
Summary: We identified an issue with the recent release of [Service Name] causing [brief description, e.g., intermittent errors].
Action: As a precaution, we have rolled back the system to the previous stable version.
Impact: Users may have experienced issues between [Start Time] and [End Time]. Service is now fully operational.
We are investigating the root cause to prevent recurrence.
5. Rollback Command Cheat Sheet
(Adapt this section to your specific infrastructure)
Kubernetes:
# Check history
kubectl rollout history deployment/my-app
# Execute Rollback (Immediate)
kubectl rollout undo deployment/my-app
# Verify
kubectl rollout status deployment/my-app
AWS / Blue-Green:
# Swap Target Groups
aws elbv2 modify-listener --listener-arn $LISTENER_ARN --default-actions Type=forward,TargetGroupArn=$PREVIOUS_TG_ARN
Database Migrations (Critical):
- Note: If a deployment includes a backward-incompatible DB migration, a rollback may fail.
- Policy: Always run DB migrations as a separate, forward-only step before the code deployment. Code must be compatible with both old and new DB schemas.