List functional requirements for the system (Ask the chat bot for hints if stuck.)...
1) URL shorting
2) URL Redirects
List non-functional requirements for the system...
1) low latency
2) Scalable
3) Consistency
Estimate the scale of the system you are going to design...
200 write qps
20000 read qps
the ratio is 1:5
Data storage
long url :100 byte
short url: 8 byte
created_at time : 8 byte
user_id: 20 byte
expiration_time 8 byte
144 byte per entry for simplicity it could be around 256 byte
Daily Data Generation
if you assume you handle 200 requests per second to create new short URLs, and considering that there are 86,400 seconds in a day, the total data generated daily would be:
Define what APIs are expected from the system...
There are two api
1) shorten url
method post
end point :/tinyurl/shorten
request :
{
"user_id":"",
"long_url":""
}
response :
{
"short_url:"",
"expiry_time:""
}
Defining the system data model early on will clarify how data will flow among different components of the system. Also you could draw an ER diagram using the diagramming tool to enhance your design...
We only need one time table for this that url_mapping
user_id : varchar
long_url : varchar
created_at : timestamp
expiry : timestamp
short_url : varchar
You should identify enough components that are needed to solve the actual problem from end to end. Also remember to draw a block diagram using the diagramming tool to augment your design. If you are unfamiliar with the tool, you can simply describe your design to the chat bot and ask it to generate a starter diagram for you to modify...
Explain how the request flows from end to end in your high level design. Also you could draw a sequence diagram using the diagramming tool to enhance your explanation...
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?