given a long url, the system should create and return a shortened URL.
when given a short url, the system should redirect the user to the corresponding long URL.
the system should track the number of clicks on each short URL.
the service should be highly available.
URL redirections should occur in under 10ms.
URL creations should occur in under 200ms.
Should be able to handle 20,000 requests/second for short url redirection.
Should be able to handle 200 requests/second for creating short URLs
assuming one redirection server can handle 1000 requests per second and 10 URL creations per second, approximately 20 redirection nodes and 20 shortening nodes are needed
dynamo db or similar can be used to store a simple key:value pair comprised of the short url hash to the long 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...
for static assets a CDN can be used that will offload load from the application servers
for api requests, route to the API gateway to handle authentication and rate limits
when shortening, check the cache for already shortened URLs. if the cache misses, generate a new URL and store it in the database
when redirecting, check the cache for the long URL. if not present in cache, check the database and redirect if found
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?