In Time behaviour, we measured a project-information request from the moment the client sent it until the complete response arrived. This chapter uses the same hypothetical G01 workload and the same response times. Of 30,000 requests in ten minutes, 29,850 return correct, authorized responses. Of those successes, 98.49% arrive within 500 ms, and the p95 is 420 ms. The service delivers 49.75 successes per second, and 0.50% of all requests end in error. All three measures meet their illustrative targets.
Did the run pass?
This chapter is about Resource utilization: which resources a system consumes while it performs work under stated conditions. None of the services, figures or results describe TDP. The run in this chapter is synthetic, and its criteria are illustrative and unapproved. It is not G01’s Run A. It keeps Run A’s workload and response outcomes, and replaces Run A’s resource observations with values invented for this chapter.
Two questions about consumption
A resource observation can serve two purposes. It can decide whether a run meets a stated budget, or it can help you look for the cause of a change. The chapter follows both paths.
Two questions about consumptionResource utilization in a scenario and in diagnosisDid the run meet the budget?Why did consumption rise?State the criterionQuantity, boundary, limit and windowMeasure in that windowKeep the same accounting boundaryDecide the verdictCheck the result against the limitMonitor consumptionFind when resource use roseRead a profileFind where sampled work occurredForm a hypothesisIdentify a possible cause to testRun a controlled comparisonTest under matched conditionsText equivalent. The budget path starts from a criterion that states what is counted, the boundary, the limit and the window. The measurement taken in that window decides whether the run passes or fails that criterion. The diagnosis path starts with monitoring, which shows when use rose. A profile shows where the sampled work occurred and suggests a hypothesis about the cause. A controlled comparison tests that hypothesis. Monitoring and profiles do not decide the budget, and a budget verdict does not explain a cause. The arrows are reading relationships between steps in this chapter, not a description of TDP. The map is an editorial summary of the chapter and of the local resource utilization concept.
The timing results pass
G01 offers simulated project-information reads against 100,000 synthetic records, with up to 100 concurrent users and a service cache that starts empty. Arrivals ramp from zero to 50 requests/s over one minute, then hold at 50 requests/s for 600 s. The assessment window is the hold, which includes the cache warming up. The ramp is outside it. The service runs on two allocated cores, a request with no outcome after 5 s is an error, and response time runs from client dispatch to complete receipt.
To keep the arithmetic reproducible, assume that all 30,000 scheduled arrivals in the hold actually arrive, with no retries, no missing outcomes and no work crossing the edges of the hold. These are teaching assumptions, not a measurement protocol.
| Input or result | Value | Calculation |
|---|---|---|
| Arrivals in the hold | 30,000 | 50/s × 600 s |
| Successful response times | 27,000 at 300 ms, 1,400 at 420 ms, 1,000 at 500 ms, 450 at 900 ms | 29,850 correct, authorized successes |
| Errors | 150 | 30,000 − 29,850 |
| Successes within 500 ms | 98.49% | 29,400 / 29,850 |
| Successful throughput | 49.75/s | 29,850 / 600 s |
| Error fraction | 0.50% | 150 / 30,000 |
| Successful-response p95 | 420 ms | Rank 0.95 × 29,850 = 28,357.5, rounded up to 28,358 |
G01 requires at least 95% of successes within 500 ms, at least 49 successes/s and an error fraction strictly below 1%. All three hold. The success population excludes the 150 errors, which still count against the arrival-based error fraction. Time behaviour explains these populations and the G01 percentile calculation gives the full distribution.
G01 also sets two resource criteria for the same hold. Each one-minute CPU average across the allocated cores must stay below 80%, and peak total service memory must stay below 2 GiB. The timing results say nothing about either.
Minute five exceeds the CPU budget
CPU time adds up the execution of every process inside the measured boundary. Two cores working at the same time can accumulate two CPU-seconds in one second of elapsed time. In one minute, two allocated cores provide 60 s × 2 = 120 CPU-seconds. A minute’s CPU percentage is the CPU time used in that minute divided by those 120 CPU-seconds.
In this run, the service uses 72 CPU-seconds in each minute except the fifth, where it uses 108.
One minute over the CPU limitSynthetic G01 hold · service CPU across two allocated cores100%50%0%60%90%80% limit12345678910Minute of the 600 s holdMinute 5 reaches 90%108 of 120 CPU-seconds · failsThe hold averages 63%756 of 1,200 CPU-secondsSynthetic run with G01’s workload and response outcomes. The CPU observations are invented for this chapter and the limit is illustrative. See the G01 scenario.
Text equivalent. Ten bars show service CPU for each aligned minute of the synthetic 600 s hold, as a share of two allocated cores. Minutes 1 to 4 and 6 to 10 each use 60%. Minute 5 uses 90% and crosses the 80% limit line. The ten-minute average is 63%. The calculations are in the table below.
| Hold minute | Service CPU time | Share of two cores | Against < 80% |
|---|---|---|---|
| 1 to 4 | 72 CPU-s each | 72 / (60 × 2) = 60% | Pass |
| 5 | 108 CPU-s | 108 / (60 × 2) = 90% | Fail |
| 6 to 10 | 72 CPU-s each | 60% | Pass |
A cumulative CPU counter, read at each minute boundary from the start of the hold, would show 0, 72, 144, 216, 288, 396, 468, 540, 612, 684 and 756 CPU-seconds. Each minute’s value is the difference between two adjacent readings. Minute five runs from 288 to 396, a difference of 108.
Over the whole hold, the service uses 756 CPU-seconds out of 600 s × 2 = 1,200 available, an average of 63%. That number is correct, and it answers a different question. The average describes the whole run. G01’s limit applies to each minute, so the run fails on CPU. A value of exactly 80% would also fail, because the criterion is strictly below 80%.
The total cannot tell you about the worst minute. Nine minutes at 60% and one at 90% give 756 CPU-seconds, and so would ten minutes at 63%. Keep the per-minute readings, or a counter you can difference at each boundary.
The minutes here are ten aligned, non-overlapping 60-second windows that start with the hold. A rolling one-minute criterion, evaluated at every possible start time, needs finer data and could find violations that aligned windows split in two. State which kind of window the criterion uses.
What a CPU percentage needs
A percentage without its denominator is ambiguous. Under a one-core convention, some tools would report the 108 CPU-second minute as 108 / 60 = 180%. Both 90% and 180% describe the same work. Record the convention with the number.
For a real observation, keep the timestamps, the effective allocation and the identity of the counter. Check which processes the counter includes, whether it was reset during the hold, whether the readings align with the windows and whether any readings are missing. If the allocation changes during a window, add up the core-seconds available in each allocation period instead of multiplying by a single core count.
Counters differ in scope. Linux
cgroup v2
reports usage_usec in cpu.stat for a control group and its descendants.
OpenTelemetry’s
process.cpu.time
reports CPU seconds by mode for one process. Check the modes and the scope
before adding series together or comparing them with a service-wide budget.
What the memory peak measures
The service’s recorded peak is 1,229 MiB. That is 1,229 / 1,024 ≈ 1.2 GiB, within the illustrative limit of 2 GiB.
| Memory budget | Value |
|---|---|
| Limit | Below 2 GiB, that is below 2,048 MiB |
| Recorded service peak over the hold | 1,229 MiB ≈ 1.2 GiB |
| Share of the limit | 1,229 / 2,048 ≈ 60% |
| Remaining below the limit | 2,048 − 1,229 = 819 MiB |
| Result | Pass |
The peak covers the service processes and the service cache during the ten-minute hold. The client, the load generator and the data dependency are outside that boundary and are measured separately. A smaller boundary, such as one process’s heap, would leave part of the service out and would not answer G01’s question about total service memory.
A peak is the maximum of a named memory quantity over a named period. If you only read memory at intervals, the highest reading is a sampled maximum. A brief spike between two readings could go unseen, so a sampled maximum can be lower than the true peak. Report the sampling interval and any gaps with it.
A recorded peak comes from an instrument that tracks the maximum itself. Check
what it accounts for and when it starts. In Linux
cgroup v2,
memory.current reports current usage for a control group and its
descendants, and memory.peak reports the highest usage since the group was
created. Its accounting includes more than an application heap, and it is not
the same as a process’s resident memory, a managed heap or a system-wide peak.
Writing to memory.peak resets it, but only for later reads through the same
open file descriptor. A collector that closes the file and opens it again reads
the peak since creation, which can include the ramp, and could report a breach
outside the hold. To cover only the 600 s hold, the collector has to reset the peak at the
start of the hold and keep that descriptor open until its final read. If you
do not know how the collector handles the file, treat the window of the peak
as unverified. Before you call any of these numbers total service memory,
establish that the instrument’s boundary matches the scenario’s.
The joint result
| Criterion | Result | Verdict |
|---|---|---|
| Successes within 500 ms, at least 95% | 98.49% | Pass |
| Successful throughput, at least 49/s | 49.75/s | Pass |
| Error fraction, below 1% | 0.50% | Pass |
| Every one-minute CPU average, below 80% | Minute 5 at 90% | Fail |
| Peak total service memory, below 2 GiB | 1,229 MiB ≈ 1.2 GiB | Pass |
| G01 as a whole | One criterion fails | Fail |
The run fails G01 because of one minute of CPU. A fast response does not show that the resource budget passed, and a high CPU reading does not, on its own, show a bottleneck or a lack of capacity. Whether the service used its resources well for the work it did is a separate question: performance efficiency relates consumption to correct, useful work.
From a CPU spike to a hypothesis
A failed minute tells you when consumption rose. It does not tell you why. The next example is separate from G01: a synthetic, production-style monitoring observation of one service instance with two allocated cores. The cumulative CPU readings fall exactly on the window boundaries.
| Window (UTC) | Arrived reads | CPU counter at start and end | Share of two cores |
|---|---|---|---|
| 10:04 to 10:05 | 3,000 | 1,000 to 1,072 CPU-s | 72 / 120 = 60% |
| 10:05 to 10:06 | 3,000 | 1,072 to 1,180 CPU-s | 108 / 120 = 90% |
| 10:06 to 10:07 | 3,000 | 1,180 to 1,264 CPU-s | 84 / 120 = 70% |
CPU use rises by 36 CPU-seconds, or 30 percentage points, in the middle window, and falls back to 70% in the next. The arrival count stays the same. The mix of requests and the work each one needs can still change, so equal arrivals do not mean equal work. On a real dashboard, compare matching windows and check the traffic mix, the instance and its revision, the cache state, the errors and the latency over the same minutes. Report missing data.
Dashboards often estimate rates from sampled counters rather than exact
boundary readings. Prometheus
rate(),
for example, handles counter resets and extrapolates to the edges of the query
range. Note which method produced a number before you compare it with an exact
difference like the ones above. The
Google SRE book
discusses how the resolution of a measurement limits what it can show.
These three windows show when CPU rose. They are not a G01 verdict, which needs the full controlled workload and its outcome checks.
What a CPU profile adds
A CPU profile records where execution was observed. In a hypothetical replay of comparable traffic, you collect two 60-second on-CPU profiles for the same service process with the same sampling configuration. Each usable sample counts once, by its leaf frame: the function that was executing when the sample was taken. The counts are invented and the names are illustrative code paths.
| Leaf frame | Reference minute | High-CPU minute |
|---|---|---|
| Response serialization | 180 | 540 |
| Other frames | 420 | 360 |
| Total usable samples | 600 | 900 |
Response serialization is the leaf frame in 180 / 600 = 30% of the reference samples and 540 / 900 = 60% of the high-CPU samples. Both its share and its sample count rise. That gives you a place to look.
The profile tells you where the sampled execution occurred. It does not tell you why serialization did more work. A leaf-frame count estimates self time, the time spent in that function itself. An inclusive count would also include the functions it called, and the two can rank code differently. Sampling can miss short events, and the shares apply only to the profiled process and the stacks the profiler could see. They cannot divide up the whole service’s CPU counter unless the coverage matches.
To test the hypothesis, run a controlled comparison. Replay the same seeded requests, compare payload sizes and serialization work, then repeat the workload and check correctness, response times and CPU use. Change one suspected factor at a time and keep the other conditions comparable.
Record the profiler and its version, the sampling method and interval, the processes covered, symbol resolution, dropped events and overhead. Microsoft’s high-CPU diagnostic guide describes the coverage limits of one .NET collection method, and its profiler troubleshooting guidance notes that dropped events can make a report incomplete or inaccurate. The profiler also uses CPU, so profiling can change the workload it observes.
Allocations, live objects and the memory budget
An allocation profile can point to a line of code in much the same way. In a separate synthetic 60-second allocation profile, the profiler estimates 640 MiB of managed allocations and attributes 480 MiB of them to creating response buffers. That is 480 / 640 = 75% of the managed allocations the profile estimates, not of every allocation the service makes, and it is a reason to inspect how the service creates those buffers.
Allocated bytes count allocation activity over an interval. Live objects are the ones that survive at a defined collection or snapshot. A service can allocate heavily and retain little. Microsoft’s .NET allocation tool documentation separates allocation paths from objects collected or retained by garbage collection. It is one tool’s description, not evidence that the G01 service runs on .NET.
| Question | Evidence that answers it |
|---|---|
| Which code allocates the most? | An allocation profile over a stated interval |
| Which buffers are still alive, and what keeps them alive? | A heap snapshot and the references that still reach those objects |
| Does the service stay within its memory budget? | The recorded service peak over the hold, with its boundary |
A heap snapshot does not cover every native or operating-system charge, and taking one can change the process. A managed heap dump can itself trigger a full garbage collection. To judge the memory budget, use the recorded service peak, not the allocation total and not the heap snapshot.
Write a resource criterion you can test
Pick one resource your own service consumes and write down:
- what you count, in which unit, and the counter or instrument that reports it;
- which processes and caches the boundary includes, and which components you measure separately;
- the window in which the limit must hold, whether the windows are aligned or rolling, and how they relate to the start of the assessment;
- the denominator for any percentage, including allocation changes during the run;
- for a peak, whether the instrument records the maximum itself or you read it at intervals, and when it was reset;
- the monitoring and profiling evidence you would use to diagnose a failure, and the controlled comparison that would test a suspected cause.
In G01, that last detail changes the verdict. The 756 CPU-seconds average 63% over the hold. Minute five reaches 90%, so the run fails G01’s per-minute criterion. The scenario template adds the criteria, the target owner and the approval status a team needs before treating any of these numbers as a target. The figures in this chapter are synthetic, and the targets are illustrative and unapproved.
Sources
- The Linux kernel documentation, Control Group v2, CPU and memory interface files.
- OpenTelemetry,
Semantic conventions for OS process metrics.
The process metric conventions are marked as in development, and
process.cpu.timeas a release candidate. - Prometheus documentation,
Query functions:
rate(). - Google, Site Reliability Engineering, Monitoring Distributed Systems.
- Microsoft, .NET documentation, Debug high CPU usage in .NET and Heap analysis tool (dotnet-gcdump).
- Microsoft, Visual Studio documentation, .NET object allocation tool and Troubleshoot profiler errors.