EngineeringSolution ArchitectSecurity and Observability
Session 04 - Incident Management & Postmortem
3 min read8 lessons in this module
Incident Severity Levels
Level
Tên
Ảnh hưởng
Response Time
Ví dụ
SEV1
Critical
Toàn bộ service down, data loss
< 15 phút
Production database corruption
SEV2
Major
Feature chính bị ảnh hưởng, workaround có thể
< 30 phút
Payment processing failed cho 30% users
SEV3
Minor
Feature phụ bị ảnh hưởng, impact thấp
< 2 giờ
Report generation chậm
SEV4
Low
Cosmetic, không ảnh hưởng function
Next business day
UI hiển thị sai format ngày
Incident Response Workflow
On-Call Rotation Best Practices
Rotation Structure
Primary on-call: 1 tuần rotation
Secondary on-call: Backup khi primary không available
Escalation: Team lead → Engineering Manager → VP Engineering
Guidelines
Aspect
Recommendation
Rotation length
1 tuần, handoff vào weekday morning
Handoff ritual
15-phút sync: open issues, recent changes, known risks
Compensation
On-call stipend + extra time-off cho incidents
Response time
SEV1: 15 phút acknowledge, 30 phút active
Tooling
PagerDuty/OpsGenie cho alerting & escalation
Shadow program
New engineers shadow 2 rotations trước khi on-call
Giảm On-Call Burden
csharp
// Automate common responses// Ví dụ: Auto-restart service khi health check failpublicclassSelfHealingHealthCheck : IHealthCheck
{
privatereadonly IHostApplicationLifetime _lifetime;
privatestaticint_consecutiveFailures = 0;
publicSelfHealingHealthCheck(IHostApplicationLifetime lifetime)
=> _lifetime = lifetime;
publicasync Task<HealthCheckResult> CheckHealthAsync(
HealthCheckContext context,
CancellationToken ct = default)
{
var isHealthy = await CheckDependencies(ct);
if (!isHealthy)
{
var failures = Interlocked.Increment(ref_consecutiveFailures);
if (failures >= 3)
{
// Kubernetes sẽ restart pod khi liveness failreturn HealthCheckResult.Unhealthy(
$"Failed {failures} consecutive health checks");
}
return HealthCheckResult.Degraded("Temporary issue detected");
}
Interlocked.Exchange(ref_consecutiveFailures, 0);
return HealthCheckResult.Healthy();
}
private Task<bool> CheckDependencies(CancellationToken ct) => /* ... */ Task.FromResult(true);
}
Communication During Incidents
Stakeholder Update Template
markdown
## Incident Update - [Incident Title]**Time**: 2024-01-15 14:30 UTC
**Severity**: SEV1
**Status**: Investigating / Mitigating / Resolved
**Impact**: [Mô tả cụ thể ảnh hưởng tới users]
### Current Situation
[Chúng ta biết gì hiện tại]
### Actions Being Taken
[Đang làm gì để fix]
### Next Update
[Thời gian update tiếp theo - thường 30 phút cho SEV1]
Communication Timeline
Time
Action
T+0
Alert triggered, on-call acknowledges
T+5
Initial assessment, declare severity
T+10
First stakeholder update (nếu SEV1/2)
T+15
War room active, roles assigned
T+30
Second update với findings
Every 30m
Regular updates cho đến resolved
T+resolve
Final update: resolved, RCA timeline
Blameless Postmortem Template
Mẫu Postmortem Document
markdown
# Postmortem: [Incident Title]## Metadata-**Date**: 2024-01-15
-**Severity**: SEV1
-**Duration**: 2 hours 15 minutes (14:00 - 16:15 UTC)
-**Authors**: [Tên người viết]
-**Reviewers**: [Tên người review]
## Summary
[1-2 câu tóm tắt incident và impact]
## Impact-**Users affected**: ~15,000 users (30% total)
-**Revenue impact**: ~$5,000 estimated lost orders
-**Duration**: 2h15m total, 1h45m user-facing impact
## Timeline (UTC)
| Time | Event |
|------|-------|
| 13:45 | Deploy v2.3.1 to production |
| 14:00 | Error rate alert fires |
| 14:05 | On-call acknowledges, begins investigation |
| 14:15 | Identified: new code path causes N+1 query |
| 14:20 | Decision: rollback to v2.3.0 |
| 14:35 | Rollback complete |
| 14:45 | Error rate returns to normal |
| 16:15 | Confirmed all queued orders processed |
## Root Cause
[Mô tả chi tiết nguyên nhân gốc - technical, không blame]
## Detection-**How was it detected?** Automated alert on error rate > 5%
-**Time to detect**: 15 phút
-**Could we have detected sooner?** Yes - canary deployment sẽ catch
## Mitigation
[Các bước đã thực hiện để khôi phục]
## Lessons Learned### What went well- Alert fired nhanh (15 phút)
- Rollback process smooth (15 phút)
- Clear communication với stakeholders
### What went wrong- Không có canary deployment
- Load test không cover new code path
- Staging environment thiếu realistic data
### Where we got lucky- Incident xảy ra vào off-peak hours
## Action Items
| Action | Owner | Priority | Due Date | Ticket |
|--------|-------|----------|----------|--------|
| Implement canary deployment | DevOps team | P1 | 2024-02-01 | INFRA-456 |
| Add load test cho order flow | QA team | P2 | 2024-02-15 | QA-789 |
| Seed staging with production-like data | Backend team | P2 | 2024-02-15 | BE-123 |
Action Item Tracking
Nguyên tắc Action Items
Specific & Measurable: "Add circuit breaker to PaymentClient" - không phải "improve resilience"
Có owner rõ ràng: Một người chịu trách nhiệm, không phải "the team"
Có deadline: Dựa trên priority, không phải "when we have time"
Tracked trong system: JIRA/Linear ticket, review hàng tuần
Priority Framework
Priority
Timeline
Criteria
P1
1-2 tuần
Prevent recurrence of SEV1/SEV2
P2
1 tháng
Improve detection hoặc mitigation time
P3
1 quarter
Process improvements, nice-to-haves
Learning From Incidents Culture
Blameless ≠ Accountable-less
Blameless: Không tìm ai để phạt - tìm systemic failures
Accountable: Action items có owner và deadline
Practices để xây dựng culture
Practice
Mô tả
Frequency
Incident Review Meeting
Team review postmortem, thảo luận lessons
Sau mỗi SEV1/SEV2
Weekly Incident Digest
Summary tất cả incidents tuần qua
Hàng tuần
Failure Friday
Intentionally break things (Game Day)
Hàng tháng
Action Item Review
Track completion của postmortem actions
Hàng tuần
Incident Metrics
MTTD, MTTR, recurrence rate
Hàng tháng
Metrics to Track
MTTD (Mean Time to Detect) = Thời gian từ lúc issue xảy ra → alert
MTTR (Mean Time to Resolve) = Thời gian từ lúc alert → resolved
MTBF (Mean Time Between Failures) = Thời gian giữa 2 incidents
Recurrence Rate = % incidents có cùng root cause lặp lại