Just what exactly am I designing here ?
Who are the users, how will they use this system ?
What are the input and outputs of the system ?
Am I designing this system for:
- 1 User
- Multiple users
- Billions of users
Should I discuss end to end experience or just the API ?
How big of a system am I actually designing ?
How much data would be produced ?
How many read write requests per second ?
-
So let's say you have 500Million monthly active users
That is 16Million users per day -> 600Thousand users per hour -> 10 Thousand users per min -> 166 users per second (These caculations may not be accurate, we are just estimating)
But this is a perfect world senario, no application in real life is perfect and no senario is perfect either
In real life traffic is unevenly distributed, so for example for an app like facebook, most people like to come home and check it. That means traffic probably increases after 5:00PM
So the question you should be instead asking is:
where are these users ?
Are these users distributed evenly geographically ? Becasuse different countries will give you different traffic patterns
How much percent of these monthly active users are actually active daily ?
Let's say our above calculations were correct, that there would be 10Thousand active users per min in worst case senario
And we have written a server that can handle roughly about 1000 people per min.
That means we'd need about 10 servers to handle the load at given time
So you have taken a big problem of 500Million active users and broken it down
Also, don't forget about the overall consumer impact of your system.
Like, you are designing a system, but will the consumer benifit from your design ? because if they don't they wont use the system
Draw stuff...
Start with high level block diagram.
Design the classes
Design what your APIs look like ? what do they take in ? what do they return ?
Write some code, what algo will you use ?
Ok, so we designed classes, but what is the primary key ?
How exaclty am I storing them ?
Pick a component they are interested in and go deep there.
Before proceeding to scale the system, we look at the bottlenecks of the system designed so far and discuss that with the interviewer.
Time to add Load balencers
Add some cache
Sharding
Remember: You NEED to have a working system before you can scale it.
Don't forget to discuss tradeoffs of big systems
Do this every time you bring up new things
Identify bottlenecks