Skip to content
Tech Atlas, home
Search
Esc
  • All roadmapsBrowse every learning path
  • ExploreFind a technology area
  • ProjectsGuided projects and builds
  • My AtlasYour learning dashboard
Lesson 1 of 5 · Concept · 15 min · revision 1

From symptom to cause: a method for slow systems

Tell symptoms from causes, read services with RED and resources with USE, locate the bottleneck tier with a step load test and a trace, and verify a fix with percentiles, throughput, saturation and per-request work.

Contentsand lesson path

What you will learn

  • Locate the bottleneck tier with a load test and distributed traces, then verify a fix with before-and-after latency percentiles, throughput and saturation.

01. Why it matters

Someone reports that checkout is slow. Within minutes the dashboards turn red: database CPU at 92%, p99 five times its usual value, errors climbing. Each graph is true, and each suggests a different fix: a bigger database, more instances, a longer timeout. Most of them show symptoms, effects you can observe. Underneath there are usually one or two causes, mechanisms in the design or code that you can change. Treating a symptom, usually with more hardware, costs money and tends to move the problem; removing the cause removes the whole chain.

Brendan Gregg calls the habits that waste time here anti-methods: looking only where familiar tools shine (streetlight), changing things at random until the problem goes away (drunk man), or handing the problem to another team (blame-someone-else). This lesson gives you a method instead, used throughout this skill: state the symptom precisely, find the saturated resource and its tier, measure the work each request does, name the antipattern, change one thing, and verify under the same load.

It builds on percentiles and load tests from API performance and on traces from observability, which are not taught again here.

02. Symptoms form a chain, and the cause is at the start

A typical chain: a release changes the order-history page to fetch each order's items with a separate query. Every line below is something you could measure:

Illustrative chain (the numbers are invented for this example)
cause       release 42 loads each order's items with its own query
              |  queries per page view: 2 -> 21
work        statements per second at 450 page views/s: 900 -> 9,450
              |
saturation  database CPU 35% -> 92%; statements queue for a CPU
              |
symptom     p99 of GET /orders/history: 140 ms -> 1.9 s
              |
symptom     mobile app times out after 2 s and retries: more load, more errors

Alerts fire at the bottom of the chain; the fix belongs at the top. Two habits help you climb it.

First, normalise by traffic: divide the work by the number of requests. "Database CPU doubled" could mean twice the users or twice the work per user, which need different fixes; "statements per page view went from 2 to 21 at the same traffic" can only mean the code changed. Per-request counters (queries, new connections, calls to other services) point at code rather than capacity, which makes them the most useful numbers in this skill.

Second, ask the counterfactual: if I removed this link, would the symptoms below it disappear? Turning off the app's retries would shrink the error spike but leave p99 high; removing the extra queries would remove every symptom below them. Gregg's problem statement method is a good start: what makes you think there is a problem, has it ever been fast, what changed recently, can you express it as latency, and who else is affected?

03. Two lenses: RED for services, USE for resources

Two checklists help you decide where to look. The RED method, popularised by Tom Wilkie, describes each service from the outside: the Rate of requests, the Errors, and the Duration as percentiles. RED tells you which service and endpoint is hurting users, and since when. Gregg's USE method describes each resource from the inside: Utilisation (the share of time it was busy), Saturation (work waiting because the resource cannot take it yet, usually a queue) and Errors. USE tells you why the service is slow. Google's SRE book lists four golden signals that cover both views: latency, traffic, errors and saturation.

Resources are not only CPUs, memory, disks and network links. Software resources have the same three properties, and in an application tier they are often the bottleneck:

  • a connection pool: the share of connections checked out, callers waiting to borrow one, timeouts while waiting;
  • a pool of worker threads or processes: busy workers, requests queued for a worker, requests rejected;
  • an asyncio event loop: the share of time it runs code, how late scheduled callbacks run (loop lag), callbacks that raise;
  • a lock: the time it is held, the threads waiting for it, and timeouts.

Two cautions. Utilisation is an average: a resource 60% busy over a minute can be saturated for seconds inside it. And a single-threaded resource can be saturated while the machine looks idle: one event loop keeping one core busy shows as 25% CPU on a four-core host. Measure the process or the loop, not only the host.

04. Locating the bottleneck tier with a load test and a trace

Production graphs mix many workloads. A load test gives you a controlled symptom: one endpoint, a known arrival rate and fixed data. Raise the arrival rate in steps and record, at each step, the throughput achieved, p50 and p99, the error rate, and the utilisation and saturation of every tier. The bottleneck is the resource that hits its limit, utilisation at its ceiling and saturation climbing, at the step where throughput stops following the offered load. An invented example, for a service whose database runs on its own host:

Illustrative step load test (invented numbers for practice)
offered  achieved   p50     p99    host CPU  app CPU  loop lag  DB CPU  pool waiting
  50/s     50/s    21 ms   48 ms      8%       31%      1 ms       9%         0
 100/s    100/s    23 ms   70 ms     16%       62%      2 ms      17%         0
 150/s    146/s    61 ms  900 ms     24%       97%     45 ms      25%         0
 200/s    151/s   1.4 s   4.8 s      25%      100%    1.3 s      26%         0

Throughput stops following the offered load between 100 and 150 requests per second, and p99 jumps at the same step. The host is three-quarters idle, the database uses a quarter of its CPU and nobody waits for a connection. But the application process runs one worker, so one core is all it can use, and it uses all of it; its loop lag, the saturation of that one-at-a-time resource, jumps from 2 ms to 45 ms and then past a second. The bottleneck is that process. Database replicas would not help; what it spends its CPU on is a question for a profiler.

A trace answers a different question: where did one request spend its time? Read it with care, because a span measures elapsed time, including waiting. A slow request:

Illustrative trace of one slow request
GET /orders/history                      1,240 ms
├─ db.pool.acquire                         610 ms
├─ db.query  SELECT ... FROM orders          3 ms
├─ db.query  SELECT ... FROM items  x20     44 ms  (about 2 ms each)
└─ http GET  pricing-service               560 ms
   └─ pricing: handler                      12 ms

The pool acquire span is waiting, not working: the database never saw those 610 ms. The pricing call took 560 ms for the caller, but the pricing handler's own span is 12 ms, so about 548 ms passed outside it: in a queue, on the network or in a busy event loop. Twenty item queries of about 2 ms each are a pattern from the next lesson.

Spans tell you where the time went; USE metrics tell you why it waited. When they disagree, such as a long database span while the database's own statistics show fast queries, the time went to a queue in front of the database.

05. Verifying a fix

A fix is a hypothesis: "if X causes the slowness, then changing X will reduce Y". Test it like one.

  • Keep the experiment fixed: the same endpoint mix, data, arrival rate and machine, and an open-loop load generator, which keeps sending on schedule when the server slows down, so queueing shows in the results. A closed-loop generator waits for each reply, so it quietly lowers the load when the server stalls; the load-testing lab calls this coordinated omission, and lesson 04 shows it.
  • Change one thing per run, so that you can tell which change caused which result.
  • Compare more than latency: p50 and p99 at the target rate, throughput, errors, the saturation of the resource you blamed, and the per-request counters. When a fix works on the cause, the counter changes first and saturation follows.
  • Read errors next to latency. Failures are often fast, so a change that makes 9% of requests fail in 2 ms can make p99 look better; the SRE book says to separate the latency of successful and failed requests.
  • Repeat each run and look at the spread: a difference smaller than the variation between identical runs is not a result.
  • Then raise the rate. If the resource you fixed was not the bottleneck at the old rate, the fix shows little there. It can show up as headroom, a higher rate before throughput flattens, but only if that resource is the next to saturate as load rises; otherwise another resource still sets the limit.

After every fix the bottleneck moves, so the method starts again; lesson 04 walks through four rounds of it.

06. Check your understanding

Practice check · 3 questions

From symptom to cause

Three questions about reading measurements before and after a change.

Q1. After Tuesday's release, database CPU rose from 40% to 95% and p99 tripled, while requests per second stayed flat. Which measurement best tells "the database got slower" apart from "the application now asks it to do more"?
Q2. At 300 requests/s a service has p50 = 42 ms, p99 = 610 ms and database CPU at 85%. A query change brings database CPU down to 40% at the same 300 requests/s, but p50 and p99 barely move. What do you conclude?
Q3. After a change, p99 at the same offered load drops from 2.1 s to 300 ms. The error rate rises from 0.1% to 9%, and most errors are 503 responses returned in about 2 ms. What should your report show?
Practice only: not graded, not saved, not evidence.

07. Apply it

Start this skill's practice task before you change any code. For the sample service in the lab, or a slow endpoint you own, write a one-page problem statement: the symptom in RED terms at a stated arrival rate, the resource you think is saturated and the USE evidence, the per-request counters you can measure, the antipattern you suspect, the one change you will make first, and the measurement that would prove you wrong. The lab compares it with what you measure.

08. Review prompt

Without looking back, explain: symptom versus cause, with a chain of your own; why to divide work by requests; what RED and USE each tell you, and a connection pool or event loop in USE terms; how a step load test and a trace locate the bottleneck, and why a span can mislead; and the checks before calling a fix a success.

References

Your progress

Reading state

Sign in to save that you finished reading this lesson.

Sign in to mark reading complete

Prove this skill

6 questions · about 5 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.
Take the skill check