Sub topic 13
Measuring playback quality and monitoring
This chapter assumes you know how adaptive bitrate (ABR) playback works, how a CDN serves segments, and basic metrics ideas such as counters, histograms, and percentiles. It covers what to measure on a video platform, how to collect it from players, and how to alert on it.
Why server health is not enough
A streaming platform can look healthy on every server dashboard and still deliver bad video. The CDN returns 200 responses, origin latency is low, and error rates are flat. Meanwhile a viewer on a congested mobile network sits on a spinner.
The reason is that the unit of success is a viewing session, not an HTTP request. A session succeeds when the video starts quickly, plays without stalling, and looks good. This is called quality of experience (QoE). Server metrics measure the supply side. QoE metrics measure what the viewer actually got.
You need both. Server metrics tell you where a fault is. QoE metrics tell you whether anyone is hurt by it.
The core QoE metrics
Most platforms track a small set of metrics. Each one maps to a specific viewer complaint.
| Metric | Definition | Viewer complaint |
|---|---|---|
| Video start time (VST) | Time from the play request to the first rendered frame | "It takes forever to start" |
| Startup failure rate | Share of play attempts that never render a frame | "It won't play" |
| Rebuffering ratio | Stall time divided by total watch time | "It keeps freezing" |
| Rebuffer frequency | Stalls per hour of playback | "It freezes again and again" |
| Average bitrate | Time-weighted bitrate of the rendition played | "It looks blurry" |
| Bitrate switches | Number of rendition changes per session | "The quality keeps jumping" |
| Playback failure rate | Sessions that end with a fatal error mid-play | "It crashed" |
| Exit before video start | Viewers who leave while waiting | "I gave up" |
Two definitions need care.
- Rebuffering ratio should exclude the initial startup wait, which is counted in VST. It should also exclude time the viewer spent paused or seeking. Without these exclusions, the number mixes several different problems.
- Average bitrate should be weighted by playback time. A session that watched 50 minutes at 720p and 1 minute at 360p should not average to the midpoint.
Research on large audiences has repeatedly found that viewers abandon slow-starting video, and that rebuffering lowers watch time. Exact thresholds vary by content and device. Treat any published number as a starting point and calibrate against your own abandonment data.
Collecting data from the player
The server cannot see stalls, so the player must report them. The usual design is a small client-side collector that listens to player events and sends batched beacons to a collection endpoint.
Events to capture:
- Play requested, first frame rendered, pause, seek, ended.
- Stall started and stall ended.
- Rendition changed, with the old and new bitrate and the reason.
- Segment download completed, with size, duration, and CDN host.
- Error raised, with a code and the URL that failed.
Each event carries a session ID, a video ID, a timestamp, and dimensions such as device type, app version, country, network type, ISP, and CDN. These dimensions are what let you slice a problem later.
The diagram below shows the data path from player to alert.
Design points for the beacon pipeline
- Batch and flush. Send events every 10 to 30 seconds and on page unload. Sending one request per event adds load and drains mobile batteries.
- Use a beacon transport that survives unload. In browsers,
navigator.sendBeaconis designed for this. Plain XHR calls are often cancelled when the tab closes, and that loses the final events of the session. - Sample carefully. At millions of concurrent sessions, you may sample. Sample by session ID, not by event, so each sampled session is complete. Never sample errors and startup failures, because they are rare and you need all of them.
- Keep beacon traffic off the media path. Send it to a separate domain or endpoint so a telemetry spike cannot slow video delivery.
- Expect loss and skew. Client clocks are wrong and beacons get dropped. Use server receive time for ordering across sessions, and client time only for durations inside a session.
Here is a small Python function that turns an ordered list of player events into per-session QoE numbers. It shows the arithmetic behind rebuffering ratio and time-weighted bitrate.
def session_qoe(events):
"""events: list of dicts sorted by 't' (seconds), with keys:
'type' in {'play', 'first_frame', 'stall_start', 'stall_end',
'bitrate', 'end'}; 'bitrate' events carry 'bps'.
"""
play_t = first_frame_t = None
stall_start = None
stall_total = 0.0
stall_count = 0
current_bps = None
last_t = None
weighted_bits = 0.0
played_time = 0.0
end_t = None
for e in events:
t = e["t"]
# Accrue bitrate-weighted time while video is playing (not stalled).
if first_frame_t is not None and stall_start is None and last_t is not None:
dt = t - last_t
if current_bps is not None and dt > 0:
weighted_bits += current_bps * dt
played_time += dt
kind = e["type"]
if kind == "play":
play_t = t
elif kind == "first_frame":
first_frame_t = t
elif kind == "stall_start":
stall_start = t
stall_count += 1
elif kind == "stall_end" and stall_start is not None:
stall_total += t - stall_start
stall_start = None
elif kind == "bitrate":
current_bps = e["bps"]
elif kind == "end":
end_t = t
last_t = t
if first_frame_t is None:
return {"startup_failed": True}
watch_time = played_time + stall_total
return {
"startup_failed": False,
"video_start_time_s": first_frame_t - play_t,
"rebuffer_ratio": stall_total / watch_time if watch_time else 0.0,
"stalls": stall_count,
"avg_bitrate_bps": weighted_bits / played_time if played_time else 0.0,
}
events = [
{"t": 0.0, "type": "play"},
{"t": 1.2, "type": "bitrate", "bps": 800_000},
{"t": 1.5, "type": "first_frame"},
{"t": 11.5, "type": "bitrate", "bps": 3_000_000},
{"t": 40.0, "type": "stall_start"},
{"t": 43.0, "type": "stall_end"},
{"t": 60.0, "type": "end"},
]
print(session_qoe(events))Running it on the sample session reports a start time of 1.5 seconds, one stall, and a rebuffer ratio of about 5 percent (3 seconds of stall in about 58 seconds of watch time).
Aggregating: percentiles, not averages
A mean start time hides the viewers who suffer most. If 95 percent of sessions start in one second and 5 percent take 20 seconds, the mean looks acceptable at about two seconds. Report the median (p50), p90, and p95 or p99 for time-based metrics.
For ratio metrics, aggregate carefully. The correct fleet-wide rebuffering ratio is total stall time divided by total watch time across all sessions. Averaging per-session ratios gives a short session the same weight as a two-hour movie, and the result is misleading.
Store histograms or sketches (such as t-digest or HDR histograms) rather than raw averages. These can be merged across servers and time windows, which averages of percentiles cannot.
Slicing to find the cause
An aggregate metric tells you something is wrong. Dimensions tell you where. A typical investigation looks like this:
- Rebuffering ratio rises globally by a small amount. Slice by CDN: one CDN is much worse than the others.
- Slice that CDN by country: the problem is limited to one region.
- Slice by ISP: a single network accounts for most of it.
- Check segment download metrics for that region: time to first byte is high, so the cause is likely cache misses or a peering problem.
Keep the dimension set bounded. Putting a video ID or session ID into a time series label creates millions of series and can crash the metrics store. Keep high-cardinality fields in the analytics store, and keep only low-cardinality fields such as CDN, country, device class, and rendition in the time series store.
Server and CDN metrics to pair with QoE
Correlate client metrics with these supply-side signals:
- CDN cache hit ratio, by bytes and by requests. A drop sends more traffic to the origin and raises start time.
- Origin request rate and latency, especially during new releases when the cache is cold.
- Time to first byte and download throughput per segment, from both CDN logs and player beacons.
- HTTP status codes, split into 4xx and 5xx. A burst of 404s often means a packaging bug or a missing segment, and 403s point to expired signed URLs.
- Transcoding queue depth and job failure rate. A growing queue means new uploads will be late to publish.
The client view and the CDN view should agree. When they disagree, suspect beacon loss or a tracking bug before suspecting the CDN.
Alerting
Alert on symptoms that viewers feel, and use cause metrics for diagnosis.
- Page on QoE. Startup failure rate and rebuffering ratio crossing a threshold for several minutes, in any major slice.
- Use baselines. Traffic follows daily and weekly cycles, so compare against the same hour last week instead of a fixed number alone.
- Require minimum volume. A slice with 20 sessions can show a 25 percent failure rate from one bad device. Set a minimum session count before alerting.
- Define a service level objective (SLO). For example, "99 percent of play attempts render a first frame within 4 seconds, measured over 28 days." Track the error budget and slow down releases when it is nearly spent.
- Alert on silence. If beacon volume drops sharply, either traffic fell or the pipeline broke. Both need attention.
Common errors
- Reporting only averages, so a bad tail goes unnoticed.
- Counting startup wait as rebuffering, or counting pauses as stalls.
- Averaging per-session ratios instead of dividing totals.
- Sampling events instead of sessions.
- Using high-cardinality labels in the time series store.
- Trusting client timestamps across devices.
- Alerting on raw CDN error counts without checking whether viewers were affected.
Exercise
Over one hour, 1,000 sessions are recorded. Nine hundred short sessions each watched 1 minute with 0 seconds of stall. One hundred long sessions each watched 60 minutes with 120 seconds of stall. What are (a) the mean of the per-session rebuffering ratios and (b) the correct fleet-wide rebuffering ratio? Which one should you report, and why?
Show answer
Short sessions have a ratio of 0. Long sessions have 120 / 3,600 = 3.33 percent (watch time here includes stall time, and the difference is small). (a) The mean of per-session ratios is (900 × 0 + 100 × 0.0333) / 1,000 = 0.33 percent. (b) Total stall is 100 × 120 = 12,000 seconds. Total watch time is 900 × 60 + 100 × 3,600 = 54,000 + 360,000 = 414,000 seconds. The fleet-wide ratio is 12,000 / 414,000 = 2.9 percent. Report the fleet-wide ratio, because it weights each second of viewing equally. The per-session mean lets many short, clean sessions hide the stalling that happens in long sessions.
Exercise
Rebuffering ratio is up in one country, and the CDN cache hit ratio for that country has dropped from 95 percent to 70 percent. Name one likely cause and one check that would confirm it.
Show answer
A likely cause is a cold or evicted cache in that region, for example after a new popular release, a cache purge, or a change in cache key rules that stops requests matching stored objects. To confirm, compare origin request rate and segment time to first byte for that region before and after the drop, and inspect the CDN logs for the cache status and cache key of the missed requests. If the misses cluster on a new title or a changed URL pattern, the cause is confirmed.
Exercise
Why should telemetry sampling be done per session instead of per event, and which events should never be sampled away?
Show answer
Sampling per event leaves incomplete sessions, such as a stall start without its stall end, so metrics like rebuffering ratio cannot be computed. Sampling per session keeps every event of the chosen sessions. Startup failures and fatal errors should never be sampled away because they are rare, and losing most of them would hide real problems.