Volume I · Part II · Chapter 5

Knowing Your Workloads

Timothy O’Brien 13 min read Free online

Give me a report showing that a machine uses a fifth of its CPU and I can make a plausible argument for shrinking it. Tell me that the machine runs a critical database and I can make an equally plausible argument for leaving it alone. Neither argument requires much knowledge of the database, which is precisely what should make us uncomfortable.

The interesting work begins when we try to explain why that fifth of the CPU is all the system uses. Perhaps nobody needs the machine anymore. Perhaps the application is waiting on a lock, or the memory is keeping an expensive set of reads away from storage. Perhaps the person who called it critical knows something about next month’s work that has never appeared in our measurements. I want to understand those possibilities before we turn either the low utilization or the word critical into an answer.

How to read this chapter

If you’re trying to decide whether to shrink a quiet machine, start with Look at utilization, waiting, and errors, then read The apparently idle resource. For a launch, start with the change in request mix and follow it through to the test you’d run.

Begin with the work, not the machine

Every web worker in our example completes 250 requests per second, with p95 latency no greater than 200 milliseconds and errors no more than 0.1 percent of offered requests. We’ve assumed the workers passed a test under a particular request mix. I want to know how much I can rely on that test when the new customers arrive.

It matters what the test calls a request. A cached description takes one request, and so does a search of years of history. They can look identical on the traffic chart and do very different things to the database. Ask whether next month’s requests will look like the ones you measured.

Brendan Gregg summarizes workload characterization as four questions: who is causing the load, why it is being called, what it consists of, and how it is changing over time.1 For capacity planning, the first and last are business questions as much as technical ones. Telemetry knows who sent last month’s requests; Product may know that next month’s will come from different customers.

Suppose the staged rollout reaches customers with much larger histories than those in the pilot. Product could be right about the extra 2,000 requests per second and Engineering could be right about the performance it measured. I’d run a fresh test with the new customers’ operations and data. Adding a safety factor to the old result leaves me guessing about what changed.

The why matters too. Two deployments of the same messaging software can carry similar ordinary traffic while one sends routine notifications and the other a holiday campaign whose messages are worthless a day late. I would rather ask the business owner which message becomes useless if it arrives tomorrow than spend another week measuring an interval in which nobody needed that answer.

Use simple arithmetic where it is useful

Some questions get a useful first answer from very little machinery. Take a hypothetical, deliberately simple workload: stateless, CPU-bound tasks on interchangeable cores, with a tested demand of 0.02 CPU-seconds per task, measured as CPU-seconds consumed divided by tasks completed over the same interval. The utilization law of operational analysis says that utilization, counted here in busy cores, equals throughput multiplied by that demand, U=XDU = XD.2 At 1,000 tasks per second, average CPU demand is:

1,000tasks/second×0.02CPU-seconds/task=20cores. 1{,}000\ \text{tasks/second}\times0.02\ \text{CPU-seconds/task} =20\ \text{cores}.

At a planning utilization of 60 percent, the first estimate is 20 / 0.60 = 33.33, rounded up to 34 cores. Under textbook queueing assumptions, one server that is 60 percent busy makes the average task wait 0.6 / (1 − 0.6) = 1.5 service times; our 34 cores, sharing one queue and about as busy, leave fewer than one task in 300 waiting at all.3 A percentage that is cautious for a pool already means real waiting for a single lock, disk, or partition consumer.

The same arithmetic shows how far the web service’s request mix can move before Chapter 4’s plan fails. With the borrowed batch workers, the service keeps 13,500 requests per second after losing a failure group, against a staged estimate of 12,000; since 13,500 / 12,000 = 1.125, the margin disappears if the average request needs 12.5 percent more of whatever limits a worker. Suppose history searches are 5 percent of the tested mix at 22 milliseconds of CPU each, against 2 for everything else: an average of 0.95 × 2 + 0.05 × 22 = 3.0 milliseconds. If the first stage’s customers push searches to 7 percent, the average becomes 0.93 × 2 + 0.07 × 22 = 3.4. A CPU-limited worker would then qualify at about 250 × 3.0 / 3.4 ≈ 221 requests per second, probably less once longer searches stretch the latency tail, and 54 of them carry about 11,900.

The two-point shift in searches is big enough to eat the entire margin. I’d use that estimate to set up the next test. See whether the work still spreads evenly across the workers and whether the database can keep up at the new mix. Those are the conditions I’d want on the slide beside any number we later ask someone to approve.

Look at utilization, waiting, and errors

Gregg’s USE method—utilization, saturation, and errors—gives resource investigation a disciplined start: for every resource, check all three. He defines utilization as the average time a resource was busy servicing work, saturation as the degree to which it has extra work it can’t service, often queued, and errors as the count of error events.4 The averaging matters. Gregg describes a customer whose CPUs were saturated although monitoring, reporting five-minute averages, never showed them above 80 percent; they were hitting 100 percent for seconds at a time. Relating busy, queued, and failing work tells us far more than sorting a spreadsheet of CPU percentages from smallest to largest.

The method extends to software resources and imposed limits: a lock’s utilization is the time it was held, its saturation the threads queued for it. In a cloud account, the limit that saturates is often an allowance, such as a container’s CPU limit or a disk’s provisioned IOPS, which is one way a machine can look idle while its workload is throttled.5

Put the customer’s work alongside the measurements. If the queue grows while the completion rate stays flat, ask where the work waits. If reported errors fall, check whether more requests are being rejected before they reach the part of the system the chart measures. It helps to have both the application engineer and the platform or database specialist looking at the same interval.

PostgreSQL exposes this kind of saturation directly. Each session in pg_stat_activity reports the event it is waiting for, if any: I/O, a heavyweight or lightweight lock, a buffer pin, or the client, among others.6 Sampled every second or so through a busy period, this query shows where active sessions spend their time:

SELECT wait_event_type, wait_event, count(*) AS sessions
FROM pg_stat_activity
WHERE backend_type = 'client backend'
  AND state = 'active' AND pid <> pg_backend_pid()
GROUP BY wait_event_type, wait_event
ORDER BY sessions DESC;

A null wait type usually means the session is on a CPU or queued in the operating system for one. If most sessions wait on Lock, another core will not shorten the wait. We need the transaction holding the lock, which Chapter 12 follows into schema design and application behavior, a long way from the smaller machine the meeting set out to buy.

I use data-bound workload for work whose limiting behavior depends materially on data access, movement, layout, state, or coordination. Disk-bound would be too narrow, as a small cache example shows. At 10,000 logical page requests per second and a 99 percent hit rate, assume each miss requires one physical read and hits require none. Physical read demand is:

10,000×(1−0.99)=100reads/second. 10{,}000\times(1-0.99)=100\ \text{reads/second}.

Suppose reducing memory moves the hit rate to 95 percent. The new demand is 10,000 × (1 − 0.95) = 500 reads per second: five times as much physical I/O from a four-percentage-point change. If our storage path can sustain 300 reads per second at the required quality, an apparently modest adjustment has crossed the service’s limit.

These are constructed numbers; a real investigation has to establish the cache behavior and the storage limit, and PostgreSQL adds a trap. Its blks_hit counter includes only hits in its own buffer cache, and its I/O statistics cannot tell a kernel page-cache hit from a read that reached storage. The documentation suggests starting shared_buffers at a quarter of a dedicated server’s memory and doubts that more than 40 percent helps, because PostgreSQL also relies on the operating system’s cache.7 Shrink the machine, and some of the cache we remove may be one the database’s hit ratio never counted.

Test the arrivals you expect to receive

The workload generator deserves the same skepticism as the system under test. A reassuring latency result means little if the test quietly stopped sending work whenever the service became slow, and many generators do exactly that by default: each simulated client waits for a response before sending its next request.

Gil Tene calls the resulting measurement error coordinated omission: the generator stops sending the requests that would have suffered most.8 In his wrk2 documentation, a 30-second run aimed at 2,000 requests per second over 100 connections included one 1.4-second server pause. Measured from when each request should have been sent, the 99th percentile was 1.27 seconds; measured from when each was actually sent, 6.04 milliseconds. About 2,800 requests were due during the pause, 7 percent of the 39,500 recorded, but 100 waiting connections could record at most 100 slow responses, too few to reach the 99th percentile.

For a fixed group of employees working through forms, waiting for the previous response before sending another may be a fair simulation. That’s a closed model. Devices reporting on a timer or people arriving from a campaign keep coming when the service slows. That’s an open model. Schroeder, Wierman, and Harchol-Balter found a vast difference in behavior between the two.9 In either case, I want to see what was offered and what the service started, finished, rejected, or left waiting, as well as timeouts and skipped requests. A test can look better simply because some of the work never got sent.

Azure Load Testing runs JMeter and Locust scripts at scale, and both tools are closed by default. Microsoft’s sizing guidance gives the rate a test can generate as virtual users divided by latency: 2,000 users produce about 100,000 requests per second at 20 milliseconds, and only 10,000 at 200.10 That is Little’s law: the average number of requests in a system equals throughput multiplied by the average time each spends there, here latency plus any scripted think time.11 It is also a quick check on any test report, whose concurrency, throughput, and latency have to reconcile. For a launch question stated as an arrival rate, I would use an arrival-rate design where the tool has one and add a fail criterion on requests_per_sec beside those on p95(response_time_ms) and percentage(error), so that a run that fell short of the intended rate fails instead of passing quietly.

I’d keep the latency histograms for the web service along with the offered rate and the number of successful completions. HdrHistogram distributions can be combined to get a p95 across runs. Averaging the displayed p95s won’t give you that result.12 If a slide is all you kept, you can’t go back to see what happened during the rough minute.

When scale changes the system

The portfolio’s capacity arithmetic multiplies workers by 250, which Chapter 2 justified by treating every configuration as having passed the same test at its full size. Neil Gunther’s Universal Scalability Law describes what that leaves out. It gives the relative capacity of NN workers, their throughput divided by that of one, as

C(N)=N1+α(N−1)+βN(N−1), C(N)=\frac{N}{1+\alpha(N-1)+\beta N(N-1)},

where α\alpha measures contention, waiting for something shared, and β\beta measures coherency, the cost of keeping copies of shared state consistent.13 With both at zero, the law is our multiplication. Small coefficients are not small in effect: a contention coefficient of 0.01 gives 54 workers the capacity of 54 / 1.53 ≈ 35, and no number of workers can reach 1/α=1001/\alpha = 100 times the throughput of one. Any coherency cost produces a peak at N=(1−α)/βN=\sqrt{(1-\alpha)/\beta}, beyond which more workers deliver less; with α=0.02\alpha = 0.02 and β=0.0002\beta = 0.0002, it comes at 70 workers.

Gunther asks for at least half a dozen measured load points and warns that the law “is not a crystal ball.” The model cannot predict bad measurements or a failure built into the system, and he describes its application to production data with mixed workloads as a current area of research. If I fit the coefficients for one schema, distribution of data and request mix, I want to see them predict measurements I kept out of the fit. I’d come back to those coefficients when the cache fills, one partition gets hot, or the new customers start asking for much more history.

In our plan, 13,500 assumes the batch machines can become equivalent to the web workers within two days and the rate holds across the configurations we’ll use. Test that rate at the new mix and include the database in the measurement. If throughput starts to flatten, find out what the workers are waiting for before buying more of them.

The apparently idle resource

The harder case is a decision due before anyone can finish the investigation. Somebody has counted the supposedly idle resource toward a savings target. The Cassandra cluster in the introduction, at 1 to 2 percent CPU, is the expensive version of that mistake.

Consider a constructed data service with an infrequent, urgent rebuild. The operating team knows it can require a large allocation, but a recent data change has left them without a representative measurement. Ordinary utilization is low, the next consequential event is near, and although the allocation could eventually be restored after removal, nobody has established that it could be restored in time.

How much warning will we get before the rebuild? If we can recover quota, get machines, and qualify them within that time, releasing them is a change we may be able to reverse. Here we still don’t know whether the next rebuild can wait that long or what it will need. I’d keep the allocation until we’ve run the test.

Put the cost of keeping the machines in front of the rebuild owner, agree on the test, and set a date for deciding again. It may be possible to run other work there in the meantime, if its owner can return the capacity in time.

What I would resist is letting the exception become permanent because everybody agrees the technology is difficult. Somebody has to sponsor the investigation and own the retained capacity, or the issue needs escalation rather than another quiet extension.

We can put a price on the trade without claiming to know the odds. Suppose the change saves $2,000 a month, or $24,000 a year, and a failure costs $400,000. With at most one such loss a year, an extra annual probability of 0.06 costs 0.06 × $400,000 = $24,000 in expectation. Does giving up the machines add more than about a one-in-seventeen chance of failure in a year? I’d put that to the rebuild owner, along with a chance to dispute the $400,000 estimate itself.

The person responsible for the business may reject that exposure even when expected cost appears favorable; FinOps usage-optimization guidance likewise asks for value-versus-risk thresholds for each workload.14 The proposal should make that exposure specific enough that the person deciding knows what they are agreeing to carry.

A record someone can challenge

I want a specialist to be able to tell us which part of the case they doubt. The web service’s tested rate, the demand forecast and Product’s judgment about the first stage need different kinds of evidence. Put them beside each other where people can see the difference:

Claim Evidence What would change it
250 requests/second per worker at p95 ≤ 200 ms, errors ≤ 0.1% Experiment: tested mix, each configuration used A different mix; a generator that could not hold its rate
Next peak of 10,000 requests/second Measurement and forecast: 16 weeks of daily one-minute peaks of offered requests Peak demand rejected or queued; sub-minute bursts
Staging adds 2,000 requests/second Business judgment: product lead, dated, staged scope only Changed scope or customers; the first stage’s peak
13,500 requests/second after losing a group Arithmetic: 54 × 250, linear within tested configurations Per-request demand on the limit rising over 12.5%
The shared database is not the limit at 13,500 None yet A database test at the new mix, before launch

Leave missing metrics blank and keep the runs that failed. If an application owner spots that we tested a different workload, I want them to be able to point to the line and say where the comparison broke.

Another month of ordinary CPU averages would leave the main question in this case unanswered. I’d spend the time finding out whether the database can serve the new customers’ searches at the rate we want to promise.

Notes and sources

  1. Brendan Gregg, Performance Analysis Methodology, https://www.brendangregg.com/methodology.html, accessed October 4, 2026. Gregg notes that the general process predates his 2013 write-up, pointing to Raj Jain, The Art of Computer Systems Performance Analysis (1991). Attaching business-change intelligence is this book’s emphasis.↩︎

  2. Peter J. Denning and Jeffrey P. Buzen, “The Operational Analysis of Queueing Network Models,” ACM Computing Surveys 10, no. 3 (1978): 225–261, https://doi.org/10.1145/356733.356735; Edward D. Lazowska et al., Quantitative System Performance (1984), chapter 3, https://homes.cs.washington.edu/~lazowska/qsp/, accessed October 3, 2026. The law holds for measured averages without distributional assumptions; it says nothing about latency.↩︎

  3. Mor Harchol-Balter, Performance Modeling and Design of Computer Systems (Cambridge University Press, 2013), chapters 13–14, https://www.cs.cmu.edu/~harchol/PerformanceModeling/book.html, accessed October 3, 2026. M/M/1 and M/M/k results; the 34-core figure, about 0.29 percent, was computed for this chapter with the Erlang C formula. Real arrivals are often burstier.↩︎

  4. Brendan Gregg, The USE Method, https://www.brendangregg.com/usemethod.html, accessed October 4, 2026. Gregg also notes a capacity-based definition of utilization; the method sets no universal utilization target.↩︎

  5. Gregg, The USE Method, https://www.brendangregg.com/usemethod.html, accessed October 4, 2026, sections on software resources (including locks) and cloud computing (hypervisor and container limits). The provider examples are the author’s.↩︎

  6. PostgreSQL 18 documentation, “The Cumulative Statistics System,” https://www.postgresql.org/docs/18/monitoring-stats.html, accessed October 4, 2026. The query ran on a disposable PostgreSQL 14 instance, using columns documented for version 18; it has not been run on PostgreSQL 18 or a production database.↩︎

  7. PostgreSQL 18 documentation, “The Cumulative Statistics System” (blks_hit, kernel page cache) and “Resource Consumption,” https://www.postgresql.org/docs/18/runtime-config-resource.html (shared_buffers), accessed October 4, 2026. The cache arithmetic is a constructed model, not benchmark data.↩︎

  8. Gil Tene, “How Not to Measure Latency,” QCon San Francisco 2012, https://qconsf.com/sf2012/dl/qcon-sanfran-2012/slides/GilTene_HowNotToMeasureLatency.pdf, accessed October 3, 2026; wrk2 README, https://github.com/giltene/wrk2, accessed October 4, 2026. The percentiles and the 39,500 requests recorded after a 10-second calibration period are from the README’s second example; the other request counts are this chapter’s arithmetic. wrk2 is an HTTP tool.↩︎

  9. Bianca Schroeder, Adam Wierman, and Mor Harchol-Balter, “Open Versus Closed: A Cautionary Tale,” NSDI 2006, https://www.usenix.org/conference/nsdi-06/open-versus-closed-cautionary-tale, accessed October 4, 2026. The workload examples are the author’s.↩︎

  10. Microsoft Learn, “What is Azure Load Testing?”, “Configure Azure Load Testing for high-scale load”, and “Load test configuration YAML”, checked October 4, 2026: supported tools, the RPS formula and 2,000-user example, and fail criteria. JMeter’s Open Model Thread Group is marked experimental; Locust’s wait time “can only constrain the throughput.” The 200-millisecond case is this chapter’s arithmetic. No Azure load test was run for this book.↩︎

  11. John D. C. Little, “A Proof for the Queuing Formula: L=λWL = \lambda W,” Operations Research 9, no. 3 (1961): 383–387, https://doi.org/10.1287/opre.9.3.383. Quantitative System Performance, chapter 3, adds think time and recommends the law for checking the consistency of measurements. It relates averages, not percentiles.↩︎

  12. HdrHistogram README, https://github.com/HdrHistogram/HdrHistogram, accessed October 4, 2026. Histograms are additive and can correct for coordinated omission when the intended interval is known; neither shows the workload was representative.↩︎

  13. Neil J. Gunther, “Universal Scalability Law,” https://www.perfdynamics.com/Manifesto/USLscalability.html, accessed October 4, 2026. Formula, ceiling, peak, and the cautions quoted; first published in 1993 as the “super serial” model. The numerical examples and limits on extrapolation are the author’s.↩︎

  14. FinOps Foundation, “Usage Optimization,” https://www.finops.org/framework/capabilities/usage-optimization/, accessed October 4, 2026. The guidance also warns about longer-cycle peaks such as month-end; it does not set thresholds for any particular workload.↩︎