2 API
This API would redirect the user to actual resource and return 302 (redirected) when success and 404 if fail
We may also want to ensure that the link encoded aren't malicious or point to dark web/denied resource. If a user tries to encode like that, we may deny the creating request
The design is straight forward, a simple (persistent) key-value store.
Since key-value stores are usually NoSQL, we don't have to worry about the scaling issue too much here
We are going to have a design where a client would hit the load balancer which would redirect our request to the appropriate application server based on the RR stateless algorithm.
The application server would first check if the url in our in memory cache(which we would know based on the cache server id and the cache is LRU)
if we get he hit, we return right here. Else we would want to check out the database NoSQL database would be able to route the request to the correct partition and return the request. if no present, return 404
Overall, I am ok if immediately after the resource is added, it takes a while for it to be fully propagated to all replicas (eventually consistency is OK). However, we do want to keep durability (making sure we don't lose the write request) and latency(make redict as quickly as possible < 20ms)
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?