Pidoku

Archive

This learning material is in the archive. It is not currently maintained and has not been updated with the latest information, so tool versions, prices and dates may be out of date.

The First Five Minutes

Module 4 Lesson 4.c 1h Difficulty 3/5

Prerequisites 3.a, 4.b

The idea in one minute#

When you are paged, your job is not to find the root cause. It is to stop the user pain, as safely and quickly as possible. The order is: acknowledge → assess impact → ask “what changed?” → mitigate → then understand. Most incidents are caused by a change — a deploy, a config push, a flag, a traffic shift — so undoing the most recent change is the most effective first move. Debugging comes after users are fine.

When the problem is not a change, a fixed checklist beats intuition: the USE method on the hosts, a short list of Linux commands, a short list of Kubernetes commands.

An analogy#

A paramedic arriving at an accident stops the bleeding before asking how the crash happened. The investigation matters — later, with the patient stable.

A picture#

flowchart TB
  P[":pagerduty: Paged"] --> ACK["1 · Acknowledge<br/><small>within 5 min</small>"]
  ACK --> IMP["2 · Impact<br/><small>SLO dashboard: who, how bad, since when</small>"]
  IMP --> BIG{"Big or<br/>spreading?"}
  BIG -->|"yes"| DECL[":i-siren: Declare an incident<br/><small>get help now (5.a)</small>"]
  BIG -->|"no"| CH
  DECL --> CH["3 · What changed?<br/><small>deploys, config, flags, traffic, dependencies</small>"]
  CH --> MIT["4 · Mitigate<br/><small>rollback, flag off, drain, scale, fail over</small>"]
  MIT --> OK{"Users OK?"}
  OK -->|"no"| DIAG["Diagnose<br/><small>USE, Linux, Kubernetes checklists</small>"] --> MIT
  OK -->|"yes"| AFTER["5 · Understand, write up,<br/>hand over"]
  class P warn
  class ACK,IMP,CH queue
  class BIG,OK queue
  class DECL warn
  class MIT compute
  class DIAG memory
  class AFTER io

How it really works#

1. Acknowledge#

Ack the page so it does not escalate, and say in the team channel that you are looking. One line: “Looking at CheckoutErrorBudgetBurnFast.”

2. Assess impact#

From the SLO dashboard and the alert:

  • Who is affected — all users, one region, one customer, one feature?
  • How bad — error ratio, latency, how fast the budget is burning?
  • Since when — the start time is the anchor for “what changed?”
  • Getting worse?

If it is big, spreading, involves data loss or security, or you are not making progress in 15 minutes — declare an incident and get help (5.a). Declaring early is cheap; a lone engineer struggling for an hour is expensive.

3. What changed?#

Look at everything that changed shortly before the start time:

Kind of changeWhere to look
Code deploysDeploy log / CI, kubectl rollout history, Argo CD history
Config pushesConfig repo history, config service audit log
Feature flagsFlag platform audit log
InfrastructureTerraform applies, cloud console audit log (CloudTrail etc.)
TrafficRequest rate by client — a new client, a bot, a marketing push, a retry storm
DependenciesTheir status pages and dashboards, your error logs by upstream
TimeCron jobs, certificate expiry, daylight-saving changes, month-end batch

A shared change log — every deploy, flag flip and config push in one stream, timestamped — is one of the highest-value tools an SRE team can build.

4. Mitigate: the generic mitigations#

These work without knowing the root cause:

MitigationWhenRisk
Roll back the latest deployStarted after a deployLow — if rollbacks are routinely practised and the DB schema is compatible
Turn off a feature flagStarted after a flag changeLow
Drain a zone, region, or bad hostFailure is localisedRemaining capacity must cope
Scale upSaturation from real demandDoes nothing for a bug; can overload a shared dependency
Fail over to a replica or secondary providerA dependency is downFailover itself can fail; split brain for databases
Shed load / rate-limit a clientOne client or traffic class is overloadingThat client is hurt on purpose
RestartMemory leak, stuck processDestroys evidence; take a heap or goroutine dump first if cheap
Block bad traffic at the edgeAttack, broken clientCollateral blocking

Prefer mitigations that are reversible and that you have done before.

5. Diagnose when it is not a change#

Linux, the first 60 seconds — Brendan Gregg’s checklist, still the best:

Shell
uptime                  # load averages: rising, falling?
dmesg -T | tail         # OOM kills, disk errors, TCP drops
vmstat 1 5              # r (run queue) > cores? si/so (swapping)? wa (I/O wait)?
mpstat -P ALL 1 3       # one hot CPU = a single-threaded bottleneck
pidstat 1 3             # which process uses the CPU
iostat -xz 1 3          # await, %util per disk
free -m                 # available memory (not "free")
sar -n DEV 1 3          # network throughput vs link speed
sar -n TCP,ETCP 1 3     # retransmits, connection rates
top                     # overview; check what you saw above

Plus the ones that catch the classic outages:

Shell
df -h; df -i                       # disk space AND inodes
ss -s; ss -tanp | head            # socket states; thousands in TIME_WAIT or CLOSE_WAIT?
journalctl -u myservice --since "15 min ago" | tail -50
cat /proc/$(pgrep -n myservice)/limits | grep -i "open files"; ls /proc/$(pgrep -n myservice)/fd | wc -l

Kubernetes, the first commands:

Shell
kubectl -n payments get pods -o wide                       # restarts? Pending? which nodes?
kubectl -n payments describe pod checkout-7d9c-abcde       # events: OOMKilled, probe failures, image pull
kubectl -n payments logs checkout-7d9c-abcde --previous    # logs of the crashed container
kubectl -n payments get events --sort-by=.lastTimestamp | tail -20
kubectl -n payments rollout history deploy/checkout
kubectl -n payments top pods                               # CPU / memory vs limits
kubectl get nodes; kubectl describe node <node> | grep -A5 Conditions   # MemoryPressure, DiskPressure

Go services: if the service exposes net/http/pprof, grab a goroutine dump before restarting — it shows exactly where every goroutine is blocked:

Shell
curl -s localhost:6060/debug/pprof/goroutine?debug=2 > goroutines.txt
go tool pprof -top http://localhost:6060/debug/pprof/heap

Write as you go#

Keep a timestamped log in the incident channel: what you saw, what you did, what happened. It costs seconds, helps anyone joining, and makes the postmortem easy.

02:14 paged CheckoutErrorBudgetBurnFast, 6% errors all regions
02:17 deploy checkout v2026.10.20-3 at 01:52 (dep update). Rolling back.
02:21 error ratio 0.05%. Mitigated. Will look at the diff in the morning.

A worked example#

A page at 10:40: p99 latency on the orders API is 8 s (normally 200 ms). No deploys today.

  1. Impact: all regions, all routes, error ratio rising (timeouts). Declare SEV-2.
  2. What changed? No deploys, no flags. Traffic is normal. The change log shows a Terraform apply at 10:31 — “rotate DB credentials”. Suspicious, but credentials do not cause slowness.
  3. Diagnose: kubectl top pods: CPU low. Logs: pq: sorry, too many clients already. The new credentials have a connection limit of 50 in the database’s role config; the old ones had 500. Connection pools are queuing.
  4. Mitigate: raise the role’s connection limit to 500 (one SQL statement, reversible). Latency back to normal at 10:52.

The program below is a small “what changed?” assistant: given the incident start and the change log, it ranks changes by how suspicious their timing is.

Code#

Go
// whatchanged.go — rank recent changes by suspicion relative to an incident start time.
package main

import (
	"fmt"
	"math"
	"sort"
	"time"
)

type change struct {
	at      time.Time
	kind    string // deploy, flag, config, infra
	service string
	what    string
}

// suspicion is high for changes shortly before the start, decays with age, and is zero after the start.
// Changes to the affected service, or anything it depends on, weigh more.
func suspicion(c change, start time.Time, affected map[string]bool) float64 {
	gap := start.Sub(c.at)
	if gap < 0 {
		return 0
	}
	s := math.Exp(-gap.Minutes() / 30) // half-ish life ~20 minutes
	if affected[c.service] {
		s *= 3
	}
	if c.kind == "config" || c.kind == "infra" {
		s *= 1.5 // config and infra changes are under-reviewed relative to code
	}
	return s
}

func main() {
	day := time.Date(2026, 10, 21, 0, 0, 0, 0, time.UTC)
	at := func(h, m int) time.Time { return day.Add(time.Duration(h)*time.Hour + time.Duration(m)*time.Minute) }
	start := at(10, 38)
	affected := map[string]bool{"orders-api": true, "orders-db": true}

	log := []change{
		{at(8, 5), "deploy", "search", "search v812"},
		{at(9, 50), "flag", "web", "enable new-header for 10%"},
		{at(10, 12), "deploy", "recommendations", "recs v77"},
		{at(10, 31), "infra", "orders-db", "terraform: rotate DB credentials"},
		{at(10, 36), "deploy", "notifications", "notif v19"},
		{at(10, 45), "deploy", "orders-api", "orders v300 (after start)"},
	}
	sort.Slice(log, func(i, j int) bool {
		return suspicion(log[i], start, affected) > suspicion(log[j], start, affected)
	})
	fmt.Printf("incident start %s — changes ranked by suspicion\n\n", start.Format("15:04"))
	for _, c := range log {
		fmt.Printf("%5.2f  %s  %-7s %-16s %s\n", suspicion(c, start, affected), c.at.Format("15:04"), c.kind, c.service, c.what)
	}
}

It is deliberately simple. The value is in having one change log that includes infrastructure and config, not only code deploys.

Remember this#

  • Acknowledge, assess impact, ask what changed, mitigate, then understand.
  • Declare an incident early if it is big, spreading, risky, or not improving in 15 minutes.
  • Generic mitigations — rollback, flag off, drain, fail over, shed — work without a root cause.
  • Use checklists: USE, the Linux 60-second list, the Kubernetes first commands.
  • Take a goroutine or heap dump before restarting if it is cheap. Write a timestamped log as you go.

Try it#

  1. Run whatchanged.go. Add a config change to orders-api at 10:20. Where does it rank?
  2. On a Linux VM, run the 60-second checklist while stress-ng --cpu 4 --io 2 runs. Which command shows each problem first?
  3. In a kind cluster, deploy a pod with a 64 MiB memory limit that allocates 200 MiB. Find the OOM kill with the Kubernetes commands above.

Check yourself#

  1. Why is “what changed?” the first diagnostic question?
  2. Name four generic mitigations and one risk of each.
  3. When would scaling up make an incident worse?
  4. What does a high r column in vmstat tell you?

Sources#

↑↓ navigate↵ openesc close

100% drag to pan · scroll or pinch to zoom · double-click to zoom in