[SysDes1][Chap. 14] Design Youtube

Design Questions

  • Required features: upload video and watch video.
  • Leverage cloud infra: Cloud storage, Content delivery network
  • Calculation:
    • Storage: 5 million DAU * 10% upload * 300 MB = 150 TB / day

CUJ: Uploading Video

  • Upload metadata
    • User sends a request to API servers with video metadata, e.g. filename, size, format etc.
    • API servers update the metadata cache and database
  • Upload the actual video
    • Videos are uploaded to original storage
    • Transcoding servers fetch videos from original storage, transcode videos and save the transcoded video to storage
      • Preprocessor splits videos into Group of Pictures (GOP), saves GOP to temporary storage and configs tasks that need to be run
      • Task Scheduler schedules tasks
      • All tasks finished and the video is transcoded
    • Transcoding servers send out signal to message queue and the corresponding handler update video metadata in cache and database

System Optimization

  • Speed: when users upload videos, split the video into GOPs and upload in parallel. Decouple components in the system and parallel as much as possible
  • Speed: Place upload center and CDN close to users
  • Safety: API servers respond with pre-signed URL for users to upload
  • Cost: Only serve most popular videos via CDN, others via servers

Other Topics

  • Scalability: API servers are stateless and can be scaled easily. Database can be scaled by replicas and sharding
  • Support live streaming.
  • Video take down: detect malicious videos and remove them.

Leave a Reply

Your email address will not be published. Required fields are marked *