shortening a long URL into a shorter string
redirect shortened string back to their original URL
handling high volume of URL shortening requests and redirects
maintaining data consistency and deduplication
I am not expecting extremely high scale given the system's overall low workload, high number of alternatives, and it being a non essential service for most users.
Suppose the APIs are HTTP, two APIs are at least necessary:
key-value stores with fast write and read speeds is great for this system. Redis or similar services are a good choice in this area. This allows for easy query from the shortened url to the original 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...
There are two major flows:
The url generation can be done via a random generation, genetic hashing algorithm or a combination of both to ensure efficiency.
There aren't that many tradeoffs as it is a relatively small system. One thing that may be different than more standard systems is the use of Redis as database, which may lead to unfamiliarity among devs and potential more work as the system scales. However, its fast query nature is arguably more important given that we would optimistically match the loading speed of entering a shortened url vs the original long url.
Given the small systems, the failure scenarios are relatively rare.
A few notable things need to be considered, especially if higher volumes are anticipated.