List functional requirements for the system (Ask the chat bot for hints if stuck.)...
Same URL can have the same tiny url
different tiny urls should point to different urls
users can delete tiny urls
users cannot update tiny urls
List non-functional requirements for the system...
high availability
low latency
authentication and authroization will not be considerred
Estimate the scale of the system you are going to design...
10000 tps for url creation
100 tps for url deletion
Define what APIs are expected from the system...
createTinyUrl
deleteTinyUrl
getOriginalUrl
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...
table with tinyUrlId and originalUrl
Primary Key is tinyUrlId and with indexes created on the originalUrl
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...
create tiny url:
users -> delete tiny urls
visit 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...
Url Generaton
Using UUID could simplify the implementation. UUID with retries should be good enough to handle the tps requirement.
Can have cache to store the tiny url mapping. However, need to be careful with the cache validation.
The main components will be a load balancer in front of a group of servers, those servers will connect to the redis cache for read purpose and database for write purpose. The cache will be updated upong tiny url creation or tiny url deletion.
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?