lets say we have 1M daily active users(DAU)
DB size Estimations :
Things to store in DB
Short URL = 8 Bytes
Long URL = 100 Bytes
CreatedDate
UserID = 50 Bytes
ID
Lets say each entry is taking around 1KB in DB
1M*1KB=10^9Bytes=1GB per day space
In 3 Years -> 1000 GB = 1TB
In 30 Years -> 10 TB
QPS :
Read QPS : 1M*100/10^5=1000 TPS
Write QPS : 1M/10^5 = 10 TPS
Cache Estimations :
We can keep cache for 24 hours : 1GB
/short-url
Type : POST
Input params : long url, userId
Header : authorization
/retrieve-url
Type : GET
Input Params : short url, userId
Header : authorization
user
url_mapping
flowchart TD
B[client] --> C{Load Balancer}
C --> D[ShortURLService]
C --> E[RetrieveURLService]
D --> F[(Database/Master)]
E --> G[(Database/Slave)]
E --> H[Redis Cache]
F<-->G
Generate URL :
Retrieve URL :
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
Explain any trade offs you have made and why you made certain tech choices...
Try to discuss as many failure scenarios/bottlenecks as possible.
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?