Create shortened URL based long URL
Get long URL based on a short URL
List non-functional requirements for the system...
Assume Every user generates 10 short URLs every day
Write QPS: 1000,000/100000 *10= 100
Let's assume that Read QPS: 100*10 = 1000
Assume that we will keep this service for 10 years, the number URLs we need to keep is: 1000,000*365*10*10 = 4 billion
Each Urls has 100 length = 4billion * 100 bytes = 4TB
Post api/v1/shorten
requestParam {longUrl: string}
return shortUrl
Get api/v1/shorturl
requestParam {shorUrl: string}
return longUrl
id: primaryKey
longUrl: string
shortUrl: string
Please check the high level diagram
The high-level design is very simple, we can just input long URL and then we can get short URL.
When we need to get long URL based on short URL, we can just input short URL and we can get long 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?