Skip to main content

Module 6: Case Studies

Video Streaming

Design YouTube/Netflix-like streaming — upload, transcoding, HLS/DASH packaging, CDN delivery, ABR, and metadata vs object storage.

Video is a storage + bandwidth + encoding pipeline. The viewer experience lives at the CDN edge — never stream fat originals from origin for every viewer.

What you will learn

  • Clarify VOD vs live and capacity assumptions (storage, bitrate, views)
  • Describe upload → process → package → CDN playback
  • Explain adaptive bitrate and chunked streaming (HLS/DASH)
  • Separate metadata control plane from object-storage data plane
  • Cover thumbnails, DRM/signed URLs, and scale knobs at interview depth
Upload to object storage, transcode into renditions, package HLS, then play from a CDN.
Store the original. Serve the renditions from the CDN, not from the upload bucket.

Clarify requirements

  • Video interviews explode without scope. Lock VOD vs live and quality targets first.
  • VOD (YouTube-like) vs live streaming (different latency pipeline)
  • Max resolution, codecs, captions, thumbnails, recommendations (optional v1)
  • Scale: daily uploads, average duration, peak concurrent viewers
  • Playback p99 startup time; geographic distribution of viewers
  • Access control: public, private, paid/DRM needs

Capacity intuition

  • Show storage and bandwidth math so CDN and object store feel justified.
  • Storage ≈ minutes × bitrate × number of renditions (+ raw original)
  • Example: 1 hour × 5 Mbps ≈ 2.25 GB per rendition (order-of-magnitude)
  • Views multiply egress — CDN hit ratio dominates cost
  • Transcode CPU/GPU is the upload bottleneck, not the API server
  • Estimate peak segment QPS roughly from concurrent viewers × segments/sec

Control plane vs data plane

  • Keep tiny metadata off the blob path. Mixing them is a common junior mistake.
  • Metadata DB: title, owner, ACL, processing state, manifest URLs, duration
  • Object storage: raw upload, encoded renditions, segments, thumbnails
  • API/app servers never stream file bytes for every viewer
  • CDN sits in front of object storage / packagers for playback
  • Jobs/queues connect upload events to workers

Upload path

  • Uploads should go straight to object storage, not through app memory.
  • Client requests pre-signed upload URL from API
  • Multipart upload for large files; resume on failure
  • On completion webhook/event → enqueue processing job
  • Virus/malware scan and format probe before expensive encode
  • Mark metadata state: uploaded → processing → ready / failed

Transcode & package

  • Precompute multiple qualities so players can adapt without re-encoding on the fly.
  • Worker fleet (CPU/GPU) transcodes into 360p/720p/1080p/… ladders
  • Package as HLS and/or DASH: short segments + manifest playlists
  • Generate thumbnails / preview sprites / waveform as side jobs
  • Store segments under content-addressed or videoId/rendition paths
  • Idempotent jobs — retries must not corrupt partial outputs

Why many encodings?

  • Networks and devices vary wildly. One bitrate cannot serve everyone well.
  • Mobile on weak LTE needs low bitrate; TV on fiber can take 4K
  • Different codecs (H.264/H.265/AV1) trade size vs client support
  • Precomputing renditions enables smooth adaptive bitrate (ABR)
  • Cost: storage × N renditions and heavy encode compute
  • Start with a small ladder; expand with popularity

Playback & ABR

  • The player drives quality. Your job is fast manifests and nearby segments.
  • Player fetches master manifest → picks a rendition playlist
  • Downloads segments; measures bandwidth/buffer; switches quality
  • CDN caches hot segments at edge PoPs close to viewers
  • Startup: prioritize lower quality first for fast first-frame
  • Seeking jumps to segment boundaries — short segments improve scrubbing

CDN, security, and access

  • Bytes are public-path expensive and leak-sensitive.
  • Signed URLs / cookies / tokens for private videos with short TTL
  • DRM (Widevine/FairPlay) when license-controlled content requires it
  • HTTPS everywhere; hotlink protection on object paths
  • Origin shield / tiered CDN to protect object storage on miss storms
  • Geo restrictions enforced at API + edge when product needs them

Live streaming note

  • If asked about live, contrast it briefly with VOD — do not derail the whole design.
  • Ingest via RTMP/WebRTC/SRT to an ingest edge
  • Transcode ladder with much tighter latency budgets
  • LL-HLS / DASH or CMAF chunked transfer for lower delay
  • DVR windows and recordings become VOD after the fact
  • Chat/reactions are a separate realtime system

Scale & failure modes

  • Encode queues and CDN misses are the usual hotspots.
  • Autoscale transcode workers on queue depth; prioritize trending uploads
  • Retry failed encodes; quarantine poison files
  • Popular video = extreme CDN hit rate; cold video may hit origin
  • Metadata hot keys for viral titles — cache aggressively
  • Partial processing: never mark ready until required renditions exist

Interview framing

  • Use this order in a video design round.
  • VOD scope + storage/bandwidth estimates
  • Draw upload → object store → queue → transcoder → segments
  • Metadata service for titles/ACL/state; CDN for playback
  • Explain ABR + why multiple renditions
  • Add signed URLs, thumbnails, and scale levers

Quick revision checklist

  • Estimate storage: minutes × bitrate × versions.
  • Separate control plane (metadata) from data plane (bytes).
  • CDN is mandatory for playback.
  • Pre-signed uploads — do not proxy giant files via API.
  • Explain ABR in one clear minute.
  • Mark processing states so clients do not play incomplete videos.

FAQs

Why multiple encodings?

Devices and networks differ. Precomputing renditions enables smooth ABR playback worldwide.

Why HLS/DASH instead of one big MP4?

Chunked streaming allows seeking, quality switching, and CDN-friendly caching of small segments. A single progressive file is worse for adaptation and edge caching.

Where should viewers download video from?

Almost always a CDN edge in front of object storage. Origin should only see misses and uploads/processing traffic.

How do private videos stay private?

Authorize in the metadata/API layer, then issue short-lived signed URLs (or cookies) for segment access. Optional DRM for licensed content.

What is adaptive bitrate (ABR)?

The player monitors network/buffer and switches among pre-encoded quality ladders listed in the manifest so playback stays smooth as conditions change.

VOD vs live — biggest design difference?

VOD can take minutes to encode offline. Live needs a continuous ingest→transcode→edge pipeline with much stricter latency and different failure handling.

Practice

Learner’s Task

  • Practice out loud for 10–12 minutes as if designing a YouTube-style VOD system.
  1. State VOD scope, target resolutions, and a rough storage estimate for 1 hour × N renditions.
  2. Draw pre-signed upload → object storage → processing queue → transcoder → HLS segments.
  3. Place metadata DB vs CDN playback path and narrate an ABR session from manifest to segments.
  4. Add one privacy control (signed URL) and one scale lever (worker autoscaling / CDN).
  5. Write a 4-sentence closing: pipeline, control vs data plane, ABR reason, and CDN necessity.