Systems Design Examples Youtube - herougo/SoftwareEngineerKnowledgeRepository GitHub Wiki

Source: https://bytebytego.com/courses/system-design-interview/design-youtube

SAUDIRU (scope, assumptions, use cases, (how much) data, input/output, request/s, who are the users)

Scope (features)

  • upload and watch a video

Assumptions

  • Supporting mobile apps, browsers, and smart TV
  • 5M daily active users
  • average daily watch time spent = 30min
  • must support international users
  • 1 GB = maximum video size
  • must support multiple resolutions per video

Calculations

  • storage
    • assume 10% of DAU upload 1 video per day -> 500k videos per day
    • average video size is 300 MB -> 150 TB per day

YouTube Upload Video Diagram

Overall Upload Design

  • Use BLOB storage to store videos
  • use video transcoding
    • accommodate various devices
    • ensure continuous playback regardless of network conditions
  • ...

Overall Watch Design

  • video is streamed

Transcoding

  • use a DAG model (e.g. Airflow)

Performance Optimizations

  • splitting a video
  • upload centres close to users
  • message queues for mass parallelism
  • use CDN for popular videos and other videos use high capacity storage video servers
  • for less popular videos, encoding can happen on-demand (save encoding storage)
  • some videos are popular in certain regions -> no need to distribute them to other regions

Other talking points

  • DB replication and sharding
  • live streaming?