SteelReed

Search

Search posts, questions…

8. Senior Skills

Handling production incidents and writing postmortems

The incident lifecycle (detect, triage, mitigate, resolve, learn), SEV levels, incident commander/comms/ops roles, the mitigation-first mindset, communication templates, debugging step by step from metrics to logs to traces, eight common backend incident patterns with signal, first action and fix, a blameless postmortem template with a worked example, action items that actually prevent recurrence, and on-call.

18 Nov 20268 min readSenior

–

At 2 a.m. the API returns 503, five people open dashboards at once, each chasing their own theory, and nobody tells customers. This post is the process that avoids that scene: who does what, the order to debug in, how to write a postmortem so the failure doesn't repeat.

1. The problem

The deploy finishes at 14:02; at 14:06 checkout fails 15% of the time. Five engineers jump into the channel: two restart pods, one raises the pool to 100, one rushes out a patch. Nobody rolls back, nobody tells customers. The incident lasts 33 minutes instead of 5, and the restarts wipe the thread dumps needed to find the cause.

2. Key idea

Like a fire crew: the commander stands back and sees the whole scene, one person reports, the rest fight the fire; the investigation comes after the fire is out.

Role Does
Incident commander (IC) coordinates, decides on rollback, calls in people; doesn't debug
Comms updates inside and outside on a schedule: what's affected, what's being done, when the next update comes
Ops / experts technical work, telling the IC before risky actions

When unsure, declare a higher SEV: downgrading SEV2 to SEV3 costs a few messages; declaring SEV3 for a real SEV1 costs the first 30 minutes.

2.1 Mitigate how?

Approach Use when Don't use when
Roll back deploy/config errors after a change (the default) a migration dropped columns, data changed format
Turn off a feature flag a new feature fails there's no kill switch
Scale out load really increased the bottleneck is the DB or downstream
Fix forward rollback is unsafe and the patch is tiny and certain you're still guessing the cause

2.2 Common incident patterns

Pattern Signal First action
Exhausted connection pool active = max, pending > 0 find what holds connections; roll back if after a deploy
Slow query after a deploy p99 and DB CPU rise right at deploy time roll back
OOMKilled exit 137, no stack trace heap dump, then restart

Restarting before collecting evidence wipes the heap, thread dumps and pool state: pull one failing pod out of the load balancer, collect evidence, then restart the rest.

3. In practice

BASH
kubectl describe pod <pod>                    # Last State: OOMKilled, Exit Code 137
kubectl logs <pod> --previous                 # logs from the container before the restart
kubectl exec <pod> -- jcmd 1 Thread.print     # thread dumps: take 2–3 a few seconds apart
kubectl exec <pod> -- jcmd 1 GC.heap_dump /tmp/heap.hprof
openssl s_client -connect host:443 -servername host </dev/null \
  | openssl x509 -noout -checkend 2592000     # exit 1 if it expires within 30 days
[SEV2] Card payments partially failing - IN PROGRESS
Impact: ~30% of card transactions failing since 14:05. E-wallets unaffected.
Doing: rolled back the 14:00 release, watching the error rate.
IC: @an  Comms: @binh  Channel: #inc-payment  Next update: 14:45

Don't try three changes at once: one hypothesis at a time.

A postmortem template
MARKDOWN
# Postmortem: <title> (SEV<n>, <date>)
## Summary          2–3 sentences: what happened, impact, how it was fixed
## Impact           who, how many, how long, what was lost (orders, money, SLO)
## Timeline         time (with time zone) | event
## Contributing factors   usually several, not one "root cause"
## What went well / where we got lucky
## Action items     task | owner | due | ticket

"Engineer A ran the wrong command" fixes nothing; "production delete commands need no confirmation" can be fixed. The "lucky" section matters: "luckily it happened during office hours" is a gap waiting for next time. Write one for every SEV1/SEV2 and near miss.

4. Working with AI

Give the AI: summarizing logs and thread dumps into groups, drafting the timeline from the incident channel, drafting the postmortem.

Check in the AI's draft:

  • The timeline has time zones and matches logs and deploy history.
  • No sentence blames a person; the question is "what let the system allow this".
  • 3–5 action items, each with an owner, due date and ticket.
  • Action items change the system (automatic guards, alerts), not "be more careful".

5. Exercises

Exercise 1: You are the IC

Deploy done at 14:02. At 14:06: /checkout p99 went from 180 ms to 4 s, 5xx at 15%. hikaricp.connections.active = 30 = max, pending = 60. DB CPU 95%, pod CPU 20%. Which SEV, what's the first action, and which two proposals do you reject?

Solution to Exercise 1
  • SEV1: checkout is the money path; downgrade later if few users are affected.
  • It matches "slow query after a deploy exhausting the pool": a full pool with waiters, high DB CPU but low pod CPU, starting 4 minutes after the deploy.
  • First action: roll back the 14:02 release; in parallel, one person captures long-running queries (pg_stat_activity by now() - query_start) and a few slow traces as evidence.
  • Reject: raising maximumPoolSize to 100 (the DB is at 95% CPU; more connections mean more concurrent queries); scaling out pods (pods aren't the bottleneck, and new ones open more DB connections).

Exercise 2: Rewrite the action items

A postmortem for an expired certificate lists: "Remember to renew certificates", "Add monitoring", "Write documentation". Rewrite them.

Solution to Exercise 2
Weak Strong
Remember to renew certificates Automatic ACME renewal (cert-manager) for every public domain; owner, due date, ticket
Add monitoring A daily openssl ... -checkend 2592000 job for every domain and internal certificate, alerting under 30 days
Write documentation An "expired certificate" runbook: check commands, manual renewal, reload, linked from the alert

Priority order: eliminate (auto-renewal) → detect early (alert) → reduce damage (runbook). Maximum public TLS certificate lifetimes are shrinking, so manual renewal no longer works.

Summary

  • Mitigate first, find the cause later; errors after a change mean roll back.
  • The IC coordinates and doesn't debug; when unsure, declare a higher SEV.
  • Debug: recent changes → metrics → logs → traces.
  • Collect evidence before restarting.
  • Blameless postmortems; action items change the system and have owners and dates.

Read more: Timeouts, retries and circuit breakers.


Self-compiled notes from official documentation and hands-on practice.

Practice interview questions on this topic

All Behavioral questions →

Loading comments…
Next on the roadmapEstimating and breaking down work when AI writes the first draft: ranges, PERT, spikes and scope negotiation