Copy-Requirements
Learn to understand the requirements to formulate a good system design.
We will present this design problem as a mock interview. Interviewer-candidate dialog is clearly marked. You might pretend to be a candidate, and think of your own reply to the interviewer’s question before reading our sample replies. After completing this design problem, you may come back and see how the design will change as per your own replies. Such an exercise will help you better understand the design space.
Design question
Interviewer: Hi, let’s design Youtube today.
Candidate: So Youtube is a video streaming service where users share, view, comment, like, and save videos.
Before designing the system, let me first understand the requirements with a bit of detail.
Functional requirements
Candidate: I see the following functional requirements:
- Upload videos
- Stream videos
- Like/dislike videos
- Add comments to videos
- Search videos according to titles
- See stats of existing videos
Non-functional requirements
Candidate: It is important to have these requirements met:
- A smooth experience in terms of streaming without any lag.
- System should be available 99.99% of the time.
- Reliability is important so that uploaded videos are not lost or damaged.
However, it is okay if an uploaded video is not seen by any two users subscribed to a channel right away. So strong consistency is not a requirement.
To summarize, the functional requirements are the features/functionalities that the user will get whereas the non-functional requirements are the expectations in terms of performance from the system.
Interviewer: Sounds the right sort of requirements for a service like Youtube. So based on the requirements, what would you plan on doing after sorting out the requirements?
Estimation
Candidate: Now that we are done with the requirements, I will do some estimation.
I believe storage is an important factor here because a lot of videos would be uploaded to Youtube on a daily basis. Furthermore, Youtube has a lot of active users i.e., the number of people watching videos regularly would be quite high.
Interviewer: Would you like to do some approximation in the form of numbers?
Candidate: Certainly, let’s assume the following:
- Total users: 1.5 billion
- Active daily users (that watch/upload videos): 500 million
- Average length of a video: 5 minutes
- Size of an average (5 minutes) video before encoding (compression, format changes, etc.): 600 MB
- Size of an average video after encoding (using different algorithms for different resolutions like MPEG-4 and VP9): 30 MB
Our system design should be horizontally scalable so that with increasing users, system keep functiong correctly.
Interviewer: Okay, so what will be your storage requirements?
Storage
Candidate: For this, we have to estimate the total number of videos uploaded to Youtube per minute.
Let’s consider that 500 hours worth of content is uploaded to Youtube per minute. Since each video of 30 MB is 5 minutes long, we require = 6 MB to store 1 minute of video.
Assuming:
...
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy