100.000 daily users, with an average of 2 shorten requests each. 200.000 requests daily for shortening processes.
For the same amount of users, we will assume they will navigate shortened links 10 times per day as a baseline (1.000.000 daily requests). It is expected that each user will do more parsing requests than shortening ones.
Each shortened url can be created with a maximum of 25 characters (25 bits). A full url, we can allow up to 100 characters (100 bits). That gives us:
For storage of these, we are looking at 15.7 mb daily for parsing requests + 3.14 mb for url shortening requests = 18.84 MB daily. Multiplying that by 30 days, we've got 565.2 MB per month in url storage.
Anticipating annual growth of 25% we've got:
We should use a NoSQL type of database, that can allow horizontal scaling. This will be used to store records permanently. Im considering using a cache layer too, with the same data structure to maximise availability when navigating through the alias to the original url.
Each record will hold:
id: UUID from each request
createdAt: Timestamp that can use it for handling cache expiration.
expiresAt: Timestamp which we could use for automatic cache expiration.
url: Original url
alias: shortened url
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?