Design a video streaming and sharing platform like YouTube or Vimeo
Role: Software Engineer
Category: System Design
Difficulty: medium
Interview Round: Other
Design a video streaming and sharing platform similar to YouTube or Vimeo. Users upload videos, the system processes them, and viewers stream them. Users also receive real-time notifications about events that concern them.
Functional requirements:
1. Video upload: support secure, efficient uploads of large video files with progress tracking.
2. Video encoding and transcoding: automatically convert videos into multiple formats and resolutions.
3. Video streaming: enable smooth playback with adaptive bitrate streaming, so quality follows the viewer's connection.
4. Notifications: provide real-time alerts for key user events.
Walk through how a video gets from the uploader's device to a viewer's screen, and how the uploader finds out it is ready.
```hint Large files
Picture a 2 GB upload that drops at 90 percent. Decide what the client resends, and whether the video bytes need to pass through your own application servers at all.
```
```hint Processing order
Transcoding is slow and can fail halfway. Work out which processing steps depend on each other, which can run at the same time, and where the system records progress so the user can be told the outcome.
```
```hint Playback
Switching quality in the middle of a video is hard if each resolution is stored as one large file. Think about what shape the stored output should have so the player can switch cheaply, and where those bytes are served from.
```
### Constraints & Assumptions
The non-functional requirements are yours to set and size. Reasonable starting points:
- Favor availability over consistency.
- Page loads under 300 ms.
- 99.9% uptime.
### Clarifying Questions to Ask
- What scale should the design handle: daily active users, uploads per day, and the largest file allowed?
- Which events trigger notifications: only "your video finished processing", or also new uploads from followed channels and comments?
- Is live streaming in scope, or only recorded videos?
- Are search and recommendations part of this design, or does playback start from a shared link?
- Do some videos need access control, such as private or unlisted videos?
### What a Strong Answer Covers
- How large uploads get from the client to storage, including progress, recovery after a dropped connection, and how much of the traffic the application servers carry.
- The processing pipeline after upload: how work is queued and ordered, how job state is tracked, and what happens when a step fails or a message is delivered twice.
- How stored video is laid out and delivered so adaptive bitrate playback works at the estimated read volume, including caching and the origin.
- How notifications reach a user in real time, with a justified protocol choice and a plan for users who are not connected.
- Storage and bandwidth estimates that drive design choices, and explicit consistency trade-offs between stores such as the metadata database and the search index.
### Follow-up Questions
- A three-hour upload takes hours to transcode on one worker. How would you shorten the time until the video is watchable?
- One video gets millions of views in its first hour while most videos are rarely watched. How do caching and storage choices differ for the two cases?
- How would the design change to support live streaming with only a few seconds of delay?
- Messages can be delivered twice and workers retry. How do you guarantee that a video that fails content validation never becomes visible?
Overview: Design a video sharing platform where users upload large files, the system converts them into multiple formats and resolutions, and viewers stream with adaptive bitrate playback and get real-time notifications. It tests upload handling, asynchronous processing, delivery at scale and capacity estimates.