Systems Thinking
Lifetime Averages Hide the Incident You Are Debugging
Cumulative lifetime metrics smooth away the operational events you care about; windowed rates, percentiles, and aligned time ranges are required for diagnosis.
- Observability
- Metrics Design
- Incident Response
- Time Series Analysis
- Operational Diagnosis
Cumulative lifetime counters smooth away the event you care about. When you are investigating a latency spike or error rate anomaly, a metric that averages everything from boot time hides the exact window where the system broke.
Why Lifetime Averages Mislead
A single aggregate number—“average latency is 150ms”—feels authoritative until you need to know whether latency just spiked to 2 seconds in the last five minutes. That 150ms average includes performance from the last six months. If the system was healthy for 180 days and broken for five minutes, the average barely budges. You see the metric and report it, and the incident gets harder to find, not easier.
Lifetime counters serve a purpose: they show long-term burn rates, total request volume, cumulative memory allocations. They are not useless. But when the system is actively misbehaving, they are the wrong tool. The event you are debugging happened recently. The metric you need must be recent too.
The problem compounds when you compare components. If one service reports a lifetime average of 100ms while a dependent service reports a lifetime average of 120ms, you cannot tell whether the dependent service is adding 20ms of latency or whether the dependent service simply had worse performance during an earlier phase of its lifetime.
Rates and Counters: Understanding the Window
A rate is a counter divided by time. “Requests per second” is more useful than “total requests since boot” when you are diagnosing current behavior. The window matters as much as the denominator.
When designing or evaluating metrics pipelines, distinguish between:
- Cumulative totals: “I have processed 50 million requests.” Useful for accounting, cost calculation, and verifying no data was lost. Useless for latency diagnosis.
- Recent rates: “In the last five minutes, I processed 1,000 requests per second.” Useful for current load analysis. Still does not tell you the shape of the distribution.
- Windowed percentiles: “The 95th percentile of latency in the last five minutes is 450ms.” Useful for incident investigation. Tells you about tail behavior, not just the median.
The choice of window is not arbitrary. A five-minute window is often too long for high-frequency events; a thirty-second window may be too short to distinguish signal from noise. During an incident, you might need sixty seconds, ten minutes, and one hour windows simultaneously to understand the scope and duration.
Rates without percentiles hide tail latency. If a service serves requests uniformly at 50ms, the average and the 95th percentile are close. If the service handles 95% of traffic in 50ms and 5% in 500ms, the average still looks acceptable while the tail is broken. Percentiles force you to see the slowest requests.
The Percentile Staircase
When investigating performance, do not stop at the mean or median. Build operational habit around the staircase:
- 50th percentile (median): Half the requests. Often misleading if the other half are much slower.
- 95th percentile: The slowest 5% of requests. Common SLA boundary. Identifies when most users start experiencing problems.
- 99th percentile: The slowest 1% of requests. Identifies the tail. If this is very high while the 95th is acceptable, you have a specific subset of requests or conditions that are broken.
- 99.9th percentile (max or near-max): The absolute worst case. Helps identify outlier failure modes or saturation patterns.
Ranking by percentile also reveals where the problem is. If the 99th percentile is only slightly higher than the 95th, the tail is relatively consistent. If the 99th percentile is five times the 95th, something sharp happens at very low traffic levels—perhaps a pathological query, a resource contention event, or garbage collection pause.
While designing observability for a system that depends on multiple backends, the 95th percentile of latency in the dependent service is not the sum of the 95th percentiles in each backend. It is higher, sometimes much higher. This is because different requests take different paths. Aligning windows and percentiles across the boundary becomes critical to understand whether the added latency is expected or a sign of uneven load distribution or a failing backend.
Aligning Windows Across Boundaries
A service A calls service B. Both export metrics. When you see a latency spike in A, you need to check whether B is the cause. But if A samples its metrics every minute and B samples every five minutes, and they do not start at the same time offset, you are comparing windows that do not overlap. The minute-aligned sample from A covers 12:00–12:01, but B’s sample covers 12:02–12:07. You see different time periods and blame the wrong service.
Practical alignment strategies:
- Use wall-clock time as the metric boundary, not a sliding window. Sample at the top of the minute, not thirty seconds after each request.
- When correlating metrics across services, ensure they share the same time zone and clock source. NTP drift or local clock skew can throw off correlation by seconds or minutes.
- Export metrics at consistent intervals. If one service exports every thirty seconds and another every five minutes, interpolate or align to a common cadence for comparison.
- Tag metrics with the sample window start and end time. A metric labeled with
window_start: 12:00:00andwindow_end: 12:01:00is unambiguous. A metric labeled only withtimestamp: 12:00:45is not.
When a trace or request spans multiple services, each service should record its own latency for its own segment, tagged with the same trace ID and windowed to the same time range. This creates a verifiable chain: if request X took 500ms end-to-end and service A spent 200ms and service B spent 150ms, then network and coordination overhead accounts for the remaining 150ms. If the numbers do not add up, something is being missed or misreported.
Diagnostic Checklist
When investigating an operational event:
- Do not trust lifetime averages. Ignore them until you have windowed data that confirms or refutes the spike.
- Start with recent percentiles. Query the 50th, 95th, and 99th percentiles for the last five and sixty minutes.
- Check whether the window is too wide. If a five-minute window shows a spike, narrow it to one minute or thirty seconds to see whether the event was brief or sustained.
- Verify percentile consistency across dependent systems. Plot 95th-percentile latency for each service on the call chain. If the total latency is very high but no service shows a high 95th percentile, suspect network latency or a scheduling delay.
- Confirm clock alignment. When correlating metrics between systems, check that sample windows start and end at the same time.
- Look for percentile skew. If the 99th percentile is much higher than the 95th, the failure is concentrated. If they are close, the failure is distributed.
- Re-aggregate only after diagnosis. Lifetime totals are useful for verification and dashboards, but not for finding the fault.
The Cost of Aligning to Real Time
Windowed metrics aligned to wall-clock boundaries cost more to store and query than sliding-window aggregates. A twelve-hour retention of one-minute samples for ten thousand metrics is 17 billion data points. Compression and time-series databases help, but the cost is real. This is why many systems start with lifetime aggregates and add windowed metrics later.
This is also why the choice of window matters operationally. A one-second window of all percentiles for all services is too much data. A one-hour window is too coarse for incident response. A five-minute window is a reasonable default for most systems, with the ability to zoom to one minute or sixty seconds during active investigation.
Grounded Takeaway
The moment you need to debug a latency spike or error rate anomaly, lifetime averages stop being useful. Cumulative counters tell you the long-term health of the system; windowed rates and percentiles tell you whether something just broke. Both categories of metrics belong in operational systems, but they answer different questions. When the incident is active, trust the window, not the lifetime. Align that window across dependencies, and verify the percentiles match your acceptance criteria. If you do not have windowed metrics, you will spend most of the incident generating them retroactively from logs—and by then, the context is already cold.
For help designing observability systems with the right metric types, shapes, and windows for your architecture, /contact.