What it is
A video streaming platform accepts uploads, converts them into formats every device can play, and delivers them to viewers worldwide with fast start and no stalls. YouTube, Netflix and Twitch differ in catalogue and live vs on-demand, but share the shape: an ingest and processing pipeline on one side, a multi-tier content delivery network on the other.
Why it exists
Raw uploads come in arbitrary formats and bitrates; viewers have phones on 4G, laptops on Wi-Fi and TVs on fibre. Serving the same file to all of them either stalls the weak connections or wastes the strong ones. And the bandwidth needed for millions of viewers is so large that no single data centre can serve it. The platform exists to encode once into many renditions and to serve them from caches near viewers.
How it works
Requirements. Functional: upload, process, publish, play on any device, seek, adapt quality. Non-functional: playback starts within a couple of seconds and rarely rebuffers; uploads never get lost; published videos are durable; time-to-publish of minutes; cost per hour watched kept low.
Estimates (illustrative). 100 000 uploads a day of 10 minutes each is about 17 000 hours of video a day. With five renditions at an average of 2 Mbit/s, one hour stores roughly 4.5 GB, so storage grows by tens of terabytes a day plus the raw files. Delivery dwarfs everything: 1 million concurrent viewers at 5 Mbit/s is 5 Tbit/s.
Upload. Clients upload in chunks with a resumable protocol (for example tus, or object storage multipart uploads with presigned URLs). Raw files are kept so videos can be re-encoded later with better codecs.
Transcoding pipeline. The video is split into chunks (a few seconds each, cut at keyframes). For each chunk and each rendition a task goes onto a queue; workers transcode tasks in parallel and write segments to storage; a final step writes the manifests. Tasks are idempotent and retryable, so workers can run on interruptible capacity and scale on queue depth or the age of the oldest task.
Adaptive bitrate. Each rendition is a sequence of 2–6 second segments listed in a manifest (HLS .m3u8 or DASH .mpd; CMAF lets both share the same segment files). The player picks a rendition per segment from measured throughput and buffer level. Everything is plain HTTP, so standard CDNs cache it.
CDN delivery. Edges near viewers cache segments. Popularity is heavily skewed (roughly Zipf-like): a small fraction of videos gets most views, so a cache much smaller than the catalogue achieves a high hit ratio. The less skewed the distribution, the more requests fall into the long tail and miss.
Origin shield. Between the edges and the origin sits a shared cache tier. All edges send misses there, so a segment fetched for one region is a hit for the others, and concurrent misses for the same segment collapse into one origin read. The origin then sees only the shield's misses.
When to use it
Any product that serves recorded or live video at scale: on-demand libraries, user-generated video, e-learning, live streaming (with a low-latency variant of the same segment-based design).
When not to
- A handful of videos with modest traffic: a managed video service or object storage plus a CDN with a single rendition is enough.
- Real-time two-way video (calls, conferencing): segment-based HTTP delivery adds seconds of latency; use WebRTC with media servers.
- Very short clips where start time matters more than adaptation: progressive download of a single small file may be simpler.
Trade-offs
| Choice | You gain | You pay |
|---|---|---|
| More renditions per video | Smoother adaptation on every network | Storage and encoding for every video, most of which are rarely watched |
| Encode the tail on demand | Lower storage and compute | First viewers wait or get fewer qualities |
| Newer codecs (HEVC, AV1) | Lower bitrate for the same quality, less egress | Much higher encoding cost, device support varies |
| Shorter segments | Faster adaptation, lower live latency | More requests and manifest updates, lower compression efficiency |
| Origin shield | Origin load cut sharply, fewer duplicate fetches | Extra hop on misses, another tier to operate |
Alternatives
- Managed video platforms that handle upload, encoding, packaging and delivery.
- Progressive download of a single MP4: simple, no adaptation.
- WebRTC for sub-second interactive streams.
- ISP-embedded caches: the largest platforms place their own cache appliances inside ISP networks; it only pays off at enormous scale.
Failure modes
- Transcoding backlog: uploads keep succeeding while time-to-publish grows; alert on the oldest task's age.
- Poison video: a corrupt upload crashes workers repeatedly; cap retries and dead-letter it.
- Cold or lost cache tier: misses jump to the next tier; without a shield they hit the origin directly.
- Viral video / premiere: thousands of concurrent requests for segments not yet cached; coalescing and pre-warming (pushing segments to edges before the start) prevent a stampede.
- Bad ABR heuristics: oscillating quality or rebuffering; measured on the client.
In production
Measure what viewers feel: start-up time, rebuffering ratio, average bitrate, playback failures, from client telemetry. On the server side watch CDN hit ratio per tier, origin egress, queue age and transcoding cost per hour of video. Use per-title or per-scene encoding to choose bitrates by content complexity. Sign URLs or use tokens for paid content and add DRM where licences require it. Keep raw uploads in cheaper storage classes and move cold renditions there too.
Common misconceptions
- "Streaming means a long-lived connection pushing video." Modern streaming is the player pulling small HTTP files.
- "A bigger cache always fixes a low hit ratio." Popularity skew sets the ceiling; the long tail still misses.
- "Transcoding is done once per video." It is done per rendition and chunk, often again later for new codecs.
- "The queue makes transcoding faster." It makes uploads independent of transcoding; capacity still sets throughput.
Interview angle
Split the design into upload/processing and delivery early. Interviewers probe: how a large upload survives network failures, how transcoding is parallelised and scaled, what ABR is and why segments are small, how much egress the system needs (do the arithmetic), why a CDN works for video (popularity skew) and what happens with long-tail content, and how the origin is protected (shield, coalescing, pre-warming). Mentioning the storage-versus-compute trade-off for rarely watched renditions stands out.
Model assumptions
The simulation is a simplified model, not a benchmark. Each transcoding request is one task (one rendition of one chunk); the upload API stores the raw chunk (about 30 ms) and enqueues the task. Each transcoder has 4 slots and needs about 1.5 s per task (lognormal, cv 0.3), about 2.7 tasks per second. Viewers request segments of 5 000 videos with Zipf popularity (exponent 1.1, then 0.7 for the long tail). Every edge cache is an LRU of 400 videos that keeps whatever its next hop answers (the origin, later the shield), so its hit ratio emerges from the popularity skew. The shield cache is an LRU of 2 500 videos that sees only the edges' real misses, and the shield coalesces concurrent misses. A failed cache returns misses while down and comes back empty when it recovers. The origin is modelled as a database with 20 connections and about 50 ms per read, about 400 reads per second. The resumable upload and ABR segment fetching are scripted illustrations; the engine does not model bitrates or player buffers. Numbers show behaviour and orders of magnitude only.