Estimate the scale of the system you are going to design...
POST /url
body: {
url: string
}
{
shortened_url: string
}
GET /url/:tinyurl
{
url: string
}
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...
Utilize a key-value store with some non-relational database like DynamoDB where the Key is the shortened URL and the value is the original URL. This allows for O(1) lookup and retrieval.
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...
Because this is such a high-read ecosystem, we should utilize primary/secondary databases to handle the higher read values. This also allows for redundancy. In the case of the primary database failure, we can promote a secondary database. We should also utilize a cache (either Redis or memcache) with LFU to store the 30 most frequently used urls for faster retrieval. We are going to use an active-passive load balancer scheme, where a load balancer listens to see if the main load balancer goes down, and in that case takes over.
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?