System designLoading progress…

Metrics, logs and traces

Define service objectives and use telemetry, failure handling and recovery procedures to protect user outcomes.

Metrics, logs and traces

Metrics (rates and distributions) show symptoms, logs describe individual events, and traces follow one request across services. Choose summaries carefully: if 95 requests take 100 ms and 5 take 2,000 ms, the mean is a healthy-looking 195 ms while the 99th percentile is 2,000 ms. Keep metric labels bounded (20 endpoints × 5 status classes is 100 series; adding a million-valued user id makes it 100 million) and keep private payloads out of telemetry.

requests that are slow (% of 100)5slow latency (ms)2000
meanp50p95p99
195 ms100 ms100 ms2000 ms
the mean looks healthy while 5% of users wait 2000 ms: only the upper percentiles show it metrics: rates and distributions (symptoms) logs: individual events traces: one request across services
endpoint (20) × status class (5) = 100 time series never put private payloads in labels or logs
Change the slow tail, then add an unbounded label.

Predict first. Does a fleet-wide mean show the slowest users' experience?

Chapter context

Reliability is measured against what users need, not whether every component reports healthy. Observability connects symptoms to evidence, while resilience and recovery determine what happens when dependencies or infrastructure fail.

Chapter reference: math, worked example & code

This section belongs to the whole chapter, so it is the same on every lesson in it and may cover a different lesson's topic. The code for the experiment you just ran is inside the experiment itself.

Math and notation

For a time-based target A over W minutes, allowed bad time is (1−A)W(1-A)W. A simplified two-replica failover availability model is 1−(1−a)21-(1-a)^2 only if failures are independent and failover is perfect. It excludes many shared-dependency and detection failures.

Worked example

A 30-day time window contains 43,200 minutes. At 99.9% time-based availability, allowed bad time is 43.2 minutes; at 99.99%, it is 4.32 minutes. Two independent 99%-available replicas with ideal failover give 99.99% in the toy model, not a general deployment guarantee.

Reference code

The following example uses the Python standard library and does not call a remote service.

from math import isclose
minutes=30*24*60
assert minutes == 43200
assert isclose((1-.999)*minutes,43.2)
assert isclose((1-.9999)*minutes,4.32)
assert isclose(1-(1-.99)**2,.9999)

Python examples are provided for study and local execution; this page does not execute Python.

Common mistakes

Availability and durability differ. An average is not a latency percentile. Backup existence is not proof of recoverability. Correlated failures can dominate replica calculations.