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 HTTP metrics. You will learn which playback metrics matter, how players report them, and how to alert on them.
Why server metrics are not enough
Your CDN can report a 99.9% success rate on segment requests while viewers still see buffering. The server cannot see stalls, startup delay, or the rendition the player chose. Quality of experience (QoE) is measured in the player, then sent to a collection service.
The core QoE metrics
| Metric | Meaning | Typical cause when bad |
|---|---|---|
| Startup time | Time from play request to first frame | Slow manifest fetch, cold CDN cache, large first segment |
| Rebuffer ratio | Stalled time divided by watch time | Throughput below the chosen bitrate, slow origin |
| Rebuffer count | Number of stalls per session | Unstable networks, aggressive ABR switching |
| Average bitrate | Mean bitrate of played segments | Conservative ABR rule, a ladder with few rungs |
| Bitrate switches | Number of rendition changes | Noisy throughput estimates |
| Playback failure rate | Sessions that end with a fatal error | Missing segments, expired signed URLs, DRM license errors |
Report percentiles for startup time, such as p50 and p95. An average hides the slow tail that drives viewers away.
Collecting player events
The player emits small events and batches them to a beacon endpoint. Each event carries a session ID, a timestamp, and context such as device, CDN hostname, and rendition.
import json
import time
import urllib.request
def send_beacon(url, session_id, events):
payload = {
"session_id": session_id,
"sent_at": time.time(),
"events": events,
}
req = urllib.request.Request(
url,
data=json.dumps(payload).encode("utf-8"),
headers={"Content-Type": "application/json"},
method="POST",
)
with urllib.request.urlopen(req, timeout=5) as resp:
return resp.status
def rebuffer_ratio(stall_seconds, watch_seconds):
if watch_seconds <= 0:
return 0.0
return stall_seconds / watch_seconds
print(rebuffer_ratio(3.0, 600.0)) # 0.005In a browser, use navigator.sendBeacon on page unload so the last events are not lost. Sample high-volume events, such as per-segment timings, if beacon traffic becomes costly.
From events to alerts
The stream processor aggregates events into time windows and groups them by dimensions. Useful dimensions are CDN, region, device type, ISP, and content ID. A global rebuffer ratio can look healthy while one CDN in one region is failing.
Common errors
- Alerting on averages. Alert on p95 startup time and on failure rate per dimension.
- Too many dimensions. Each combination creates a separate series. Keep high-cardinality values such as session ID out of metric labels and keep them in raw logs.
- Ignoring client clocks. Use durations measured on the device, and use server receive time for ordering.
- Counting intentional pauses as stalls. Count a stall only when playback wants to advance and has no data.
- Missing the join with server logs. Include the CDN request ID or segment URL in events so you can trace a bad session to an edge or origin problem.
Exercise
Overall rebuffer ratio is 0.4%, but support tickets are rising. Which step would you take first to find the cause?
Show answer
Break the rebuffer ratio down by dimensions such as CDN, region, ISP, and device. A localized failure, such as one CDN in one region, is hidden in the global figure. Then use the segment URL or CDN request ID in the events to compare against edge and origin logs.