Interview prep notes

Revision a2b30a0aa2c2df14f136305dd5c7fa1fd7477539

videostream.md Raw

System Design Interview: Designing a Video Streaming Service (YouTube-style)

This question is mostly about the upload pipeline and efficient delivery, not the database.

Requirements

  • Users upload videos; others watch them on phones, laptops and TVs with smooth playback.
  • Playback adapts to network speed.
  • Example scale: 5M daily viewers, 500k uploads a day, average video 300 MB before processing.

Upload path

  1. The client asks the API for an upload URL and gets a pre-signed URL to object storage, so large files bypass your app servers.
  2. Large files use resumable / multipart uploads so a dropped connection doesn't restart from zero.
  3. When the upload completes, storage emits an event onto a queue.

Processing pipeline

Workers pull jobs and transcode the original into several resolutions and bitrates (for example 240p to 1080p) and codecs. Each rendition is split into short segments (2-6 seconds) with a manifest file (HLS .m3u8 or DASH .mpd).

Model it as a DAG: split into chunks, transcode chunks in parallel, generate thumbnails, run content checks, then merge and publish. Parallel chunk transcoding is what keeps a 1-hour video from taking hours.

Playback path

  • Segments and manifests are served from a CDN, which absorbs nearly all read traffic.
  • The player uses adaptive bitrate streaming: it measures throughput and switches renditions between segments.
  • Popular videos stay hot in the CDN; long-tail videos may be fetched from origin storage on demand.

Metadata

A relational or wide-column store holds video records (owner, title, status, renditions). View counts are high-write, so buffer them (stream into a counter service and flush in batches) rather than updating a row per view.

Trade-offs to mention

  • Transcoding every upload to every resolution costs compute and storage; you can transcode rare resolutions lazily.
  • CDN cost is the largest bill; regional caching and good cache keys matter.
  • Copyright and safety checks add latency before a video goes public.

Disclosure: I help build Linkjob AI, a tool for live interview support.