Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

README.md

How to approch System design

Goals

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 ?


Scope

Am I designing this system for:

  • 1 User
  • Multiple users
  • Billions of users

Should I discuss end to end experience or just the API ?


Capacity estimation

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
On basis of all this, you can scale the system
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


High Level diagram

Draw stuff...
Start with high level block diagram.


Code

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 ?


Define a data model

Ok, so we designed classes, but what is the primary key ?
How exaclty am I storing them ?


Detailed component design

Pick a component they are interested in and go deep there.


Bottleneck of the system designed so far

Before proceeding to scale the system, we look at the bottlenecks of the system designed so far and discuss that with the interviewer.


Scale the system

Time to add Load balencers
Add some cache
Sharding
Remember: You NEED to have a working system before you can scale it.


Tradeoffs

Don't forget to discuss tradeoffs of big systems
Do this every time you bring up new things
Identify bottlenecks