Diagrammatic

Video Streaming Platform — System Design Interview Practice

Design a video streaming service like YouTube or Netflix that can serve millions of concurrent viewers. Work through the requirements, architecture trade-offs, and an interactive design review.

Concepts and architecture decisions to consider

  • video streamingConcept to explore
  • cdnConcept to explore
  • transcodingConcept to explore

Interview prompt

Design upload, encode, catalog, adaptive streaming, CDN delivery, and playback so users can play a video at an adaptive bitrate reliably at scale.

  • Define the source of truth for video metadata and encoded assets and make retries idempotent.
  • Use bounded, partitioned state to meet 100M daily viewers and 10M concurrent streams and startup p95 <=2s.
  • Separate the critical request path from encoding, thumbnails, recommendations, and analytics.
  • Explain consistency, failure recovery, authorization, observability, and a degraded mode.

Requirements and scale assumptions

  • Support the core workflow to play a video at an adaptive bitrate.
  • Expose status, results, and freshness appropriate to upload, encode, catalog, adaptive streaming, CDN delivery, and playback.
  • Support authorization, validation, updates, deletion, and recovery semantics.
  • Meet startup p95 <=2s under normal load.
  • Scale to 100M daily viewers and 10M concurrent streams without a single hot key or unbounded synchronous work.
  • Do not lose committed state; make retries and duplicate events safe.
  • Degrade safely when downstream workers, caches, or external dependencies fail.
  • 100M daily viewers and 10M concurrent streams
  • Partition by the primary tenant, user, item, or geographic key and isolate hot partitions.
  • Keep serving state bounded; retain raw events or durable records for replay and auditing.
  • Peak scale: 100M daily viewers — Capacity assumption that drives partitioning and backpressure.
  • Latency target: startup p95 <=2s — User-facing budget for the primary request or read path.
  • Durable boundary: Committed before async — The source of truth is video metadata and encoded assets.
  • Async boundary: At-least-once workers — Keep encoding, thumbnails, recommendations, and analytics off the synchronous path.

Key entities

  • MediaAssetassetId, ownerId, sourceUri, checksum, privacy, status

    Canonical uploaded video streaming platform asset and lifecycle state.

  • MediaRenditionassetId, profile, codec, uri, checksum, status

    Derived video streaming platform output identified by a deterministic profile and content hash.

  • PlaybackSessionsessionId, assetId, viewerId, entitlementVersion, edgeRegion, expiresAt

    Short-lived video streaming platform access session that binds authorization to delivery.

  • ProcessingJobjobId, assetId, operation, attempt, checkpoint, status

    Retry-safe video streaming platform processing job with checkpoints and per-rendition progress.

Data flow

  1. 1. Reserve a resumable uploadThe video streaming platform gateway authenticates the owner, reserves metadata, validates size and checksum, and returns a scoped upload URL.
  2. 2. Commit and verify the sourceA completion callback verifies the video streaming platform object, records an immutable checksum, and publishes a processing job only once.
  3. 3. Process renditions asynchronouslyWorkers execute video streaming platform transforms with deterministic profiles, checkpointing, bounded retries, and a dead-letter path for corrupt inputs.
  4. 4. Publish an entitlement-aware manifestA manifest projection exposes only completed video streaming platform renditions and carries policy, checksum, and freshness metadata.
  5. 5. Deliver, invalidate, and recoverCDN delivery is protected by expiring URLs and revocation signals; failed video streaming platform jobs and stale manifests are replayable without duplicating outputs.

Deep dives and trade-offs

  • Integrity and idempotent processingUse checksums and immutable source objects for video streaming platform deduplication and audit. Derive output keys from asset, profile, and transform version so retries cannot corrupt a completed rendition. Make completion callbacks and worker claims conditional on job version and attempt.
  • Authorization at the edgeBind video streaming platform manifests and signed URLs to the viewer, entitlement version, and expiry. Propagate takedown, privacy, and subscription changes to edge caches with bounded revocation delay. Never let a cache hit bypass the policy decision for private or paid content.
  • Cost, hot assets, and backpressureSeparate interactive manifest latency from expensive video streaming platform processing and encode work. Use queue priority, concurrency limits, and lifecycle policies for source and rendition storage. Measure cache hit rate, startup latency, processing backlog, failed bytes, and egress cost by profile.
  • Process on upload versus on demandPrecompute common video streaming platform profiles and generate rare profiles on demand with a durable job state. Generating every possible profile up front wastes storage and processing budget.
  • Origin storage versus CDN cachingKeep the origin authoritative and use CDN caching for immutable or versioned outputs with explicit invalidation. A cache cannot be the only copy of a video streaming platform rendition or the recovery path becomes undefined.
  • Quality versus delivery costChoose profiles from device, bandwidth, and business requirements, then measure quality and egress by cohort. Maximal bitrate or resolution can make tail startup and cost unacceptable without improving viewing outcomes.
Diagrammatic — system design practice and architecture review.