List functional requirements for the system (Ask the chat bot for hints if stuck.)...
A user should be able to generate a short URL
A user should be able to view the short URLs they have created
A user should be able to remove a short URL they have created
A user clicking on the short URL should be redirected to the expected long URL
Short URLs should be valid for 5 years
List non-functional requirements for the system...
Upon clicking a short URL, users should be redirected with minimal latency (<300ms)
After 5 years, a short URL should expire so that storage does not grow boundlessly
Creating a short URL should occur with minimal latency (<500ms since there is some computation involved with hashing and data storage)
Estimate the scale of the system you are going to design...
This solution should be able to support 5 million users per day
Since US and European users are active during 14 hours of the day, assume we need to be able to handle ~350,000 users per hours, which calculates to ~100 requests per second. These will be reads, since we can assume there is a 100:1 read to write ratio.
Our system will need to be able to handle 100 requests per second.
Define what APIs are expected from the system...
We will need 4 total API endpoints:
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...
I would use a NoSQL database for this use case, since the common case is retrieval and a key-value store is efficient for this case where the key is the short URL and the value is the long URL. . DynamoDB is a good candidate if we are using AWS cloud services, since it provides sub-10ms retrieval times, though we will likely discuss a cache later since it is very likely 20% of the links will get ballpark 80% of the traffic based on the pareto principle that a few popular posters will garner the most interactions.
We must also address the user experience for users creating and deleting short links, which we can handle using DynamoDB by using a one table approach where we generate user items with user ID as the key, creation timestamp as the sort key so we can easily retrieve created links in order from most recently created to least recently created, and the short link metadata as the attributes, including the key for the short URL that will be deleted if the user chooses to remove that particular short URL.
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?