Appendix B: Error catalog
What this appendix is for: You have a symptom and are looking for a place to start. Each entry says how the problem shows up, which measurement narrows it down, what the cause was and how it was fixed. All entries come from the diagnosis tasks of this course; the numbers are the ones from the lab. The days in parentheses lead to the complete solution path.
Overview
| No. | Symptom (as reported) | Cause | Day |
|---|---|---|---|
| B1 | “Server sluggish, CPU not full” | many small writes with fsync |
2 |
| B2 | “Load above 4 on 4 CPUs, we need more CPUs” | I/O limit io.max in a cgroup |
3 |
| B3 | “Every job takes four times as long, load 16” | more computing threads than CPUs | 4 |
| B4 | “Script too slow, move it to a bigger server” | inefficient code (strlen in the loop, in
on a list) |
5 |
| B5 | “Memory dropping since the deployment” | memory leak | 6 |
| B6 | “Job hangs, CPU almost idle, everything sluggish” | soft memory limit too small → swap storm | 7 |
| B7 | “Only a few hundred events per second, order a faster disk” | fsync after every line |
8 |
| B8 | “Backup too long, package installation hangs” | slow device, global sync waits along |
9 |
| B9 | “New disk: 3.2 GB/s with dd” |
measured from the page cache | 10 |
| B10 | “Download takes forever, both servers relaxed” | 1 % packet loss | 11 |
| B11 | “Throughput for short connections collapsed” | nf_conntrack_max too small |
12 |
| B12 | “Python is just slow” (one CPU full) | file reread for every job | 13 |
| B13 | “Every now and then a second, CPU not busy” | synchronous archiving inside the request | 14 |
| B14 | “top shows almost nothing, still slow” | CPUQuota too small |
15 |
| B15 | “Shop terribly slow” | neighbor with high CPUWeight, forgotten
netem, computing per request |
16 |
The entries
B1 – Sluggish, but the CPU is not full
- First measurement:
vmstat 1 5– columnb(blocked processes) > 0 andwahigh;iostat -sxz 1 5– many small writes;cat /proc/pressure/io. - Narrow it down: processes in state
D(ps -eo stat,pid,comm), the journal threadjbd2active, via/proc/PID/cgroupto the service. - Cause: a program writes many small blocks and calls
fsyncafter each. - Fix: sync less often or batch. (Day 2)
B2 – High load with an idle CPU and an idle disk
- First measurement:
uptime– load 4.4 on 4 CPUs;mpstat– CPU almost idle;iostat– disk almost idle. - Narrow it down: the load also counts processes in
state
D. The waiting processes are in a cgroup withio.max; the cgroup’sio.pressureis high. - Cause: an I/O limit in a service’s cgroup.
- Fix: raise or remove the limit – not “more CPUs”. (Day 3)
B3 – Four times slower, load 16
- First measurement:
vmstat 1–r≈ 16 on 4 CPUs;runqlat-bpfcc– long waits for the CPU. - Cause: 16 computing workers on 4 CPUs. More threads than CPUs do not increase throughput (measured 2,980 versus 2,903 operations per second), only the latency of every job.
- Fix: as many computing workers as CPUs. (Day 4)
B4 – A script takes too long
- First measurement:
perf record -gandperf report, flame graph. - Cause:
strlenin the loop condition (fix: 8× faster); a test withinon a list instead of a set (fix: 20× faster). - Fix: change the code. A bigger server would have solved neither. (Day 5)
B5 – Memory dropping steadily
- First measurement:
free -m–availabledropping;ps -eo pid,rss,comm --sort=-rss. - Narrow it down:
pidstat -r -p PID 1– RSS grows by 11.5 MB/s;sar -r; the cgroup’smemory.current. Extrapolated: 16 minutes until memory is full. - Cause: a leak in the service (call chains with
memleak-bpfcc, Day 7). - Fix: close the leak in the code; until then,
MemoryMaxas protection. (Day 6)
B6 – A job hangs, the CPU is almost idle
- First measurement:
vmstat 1–si/so> 0;cat /proc/pressure/io– high (82 %), although it is a memory problem. - Narrow it down: the cgroup’s
memory.events(highrising);grep VmSwap /proc/PID/status. - Cause: during the deployment,
MemoryHighwas set to 600 MiB, the working set is larger. The kernel keeps swapping out and bringing back. - Fix: set the limit to match the working set. (Day 7)
B7 – Few events per second, disk “fast”
- First measurement:
iostat -sxz 1– many small writes, disk busy anyway;syscount-bpfcc -p PID– onefsyncper line. - Cause:
fsyncafter every line: 482 lines per second. With onefsyncper 1,000 lines, 120,000 lines per second, with less load on the disk. - Fix: batch – if the business allows it (how many events may be lost in a crash?). (Day 8)
B8 – Backup slow, package installation hangs
- First measurement:
ps -eo stat,pid,comm– processes inD, aflushthread for one particular device;iostat -x– 216 msawaiton the archive device versus 3 ms on the others. - Cause: a device with 200 ms delay. A global
sync(from the package installation) waits for all devices: up to 13 instead of 0.06 seconds. - Fix: replace the device; until then, limit the write load on it. (Day 9)
B9 – The new disk is “amazing”
- First measurement: repeat the test with
oflag=direct/iflag=directorfio --direct=1, afterecho 3 | sudo tee /proc/sys/vm/drop_caches. - Cause:
ddread from the page cache, not from the disk. - Fix: benchmarks that bypass the page cache, with the spread over several runs. (Day 10)
B10 – Download forever, both servers relaxed
- First measurement: on the sender
sar -n ETCP 1–retrans/shigh;ss -ti–retrans, smallcwnd;tc -s qdisc–dropped. - Cause: 1 % packet loss: a 300 MB download about 20 times slower.
- Fix: remove the source of the loss (here a
netemrule). Only the sender sees retransmits. (Day 11)
B11 – Short connections collapse
- First measurement:
sudo dmesg -T | tail–nf_conntrack: table full, dropping packet;sysctl net.netfilter.nf_conntrack_count net.netfilter.nf_conntrack_max. - Cause:
nf_conntrack_max = 2048: 34 instead of 4,453 requests per second. - Fix: set the limit to match the connection rate
(permanently in
/etc/sysctl.d/). (Day 12)
B12 – “Python is just slow”
- First measurement:
pidstat -u– 77 %%usr, 23 %%system;perf trace -sorsyscount– nine system calls per job, manyopenat. - Cause: the service rereads its settings file for every job.
- Fix: read it once: 600,000 instead of 18,000 jobs per second. (Day 13)
B13 – Every now and then almost a second
- First measurement: response times as a distribution
(p99, maximum), not as an average;
syscount-bpfcc -L–openatandfsyncwith a long total duration. - Narrow it down: bpftrace histogram on
fsync;biolatency-bpfcc. - Cause: every 200th request archives 256 MB
synchronously (
openat+write+fsync≈ 0.8 s). Caution:syscountdid not show the longwrite– cross-check with bpftrace. - Fix: archiving in its own thread: p99 4.9 ms instead of 915 ms. (Day 14)
B14 – Machine idle, service slow
- First measurement:
mpstat– 91 % idle;pidstat -p PID–%CPUan even 30,%wait24. - Narrow it down: the cgroup’s
cpu.stat–nr_throttled81 of 90 periods;systemctl show -p CPUQuotaPerSecUSec– 300 ms. - Cause:
CPUQuota=30%in the unit. - Fix: raise or remove the quota: 74 instead of 19 requests per second. (Day 15)
B15 – Several causes at once
- First measurement:
wrk --latency– 8.4 requests per second, median 922 ms. - Findings in order:
- CPU saturated by a background service with
CPUWeight=900→ weight 10: 32 requests/s. - RTT 15.7 instead of 0.6 ms because of a forgotten
netem→ single requests faster, throughput unchanged. - 93 % of the CPU time in a function that needlessly computes on every request → 682 requests/s.
- CPU saturated by a background service with
- Lesson: measure again after every fix; the next bottleneck was hidden before. (Day 16)
From the symptom to the first measurement
| When you hear … | … you first measure |
|---|---|
| “The CPU is full” | pidstat 1 5 and systemd-cgtop -c – who,
and is it allowed to? |
| “The CPU is idle, but it’s slow” | vmstat 1 5 (b, wa),
cat /proc/pressure/*, the cgroup’s
cpu.stat |
| “Load is high” | vmstat 1 5: r (CPU) or b
(I/O)? |
| “Memory is filling up” | free -m (available),
ps --sort=-rss, pidstat -r |
| “Everything hangs, the disk is rattling” | vmstat 1 5 (si/so),
/proc/pressure/io, memory.events |
| “The disk is slow” | iostat -x 1 5 per device,
biolatency-bpfcc -D |
| “The network is slow” | ping against the baseline, sar -n ETCP 1
on the sender, tc -s qdisc |
| “Very slow every now and then” | p99 and maximum, then histograms (bpftrace hist,
biolatency) |
| “The code is just slow” | perf record -g and syscount -L – compute
time and waiting time |