URL creation:
Short URL usage:
As the given compute requirements are not very high the hardware requirements are correspondingly low. It is more crucial to have the right architecture, like a micro-services architecture which allows to properly scale and serve 6000 users per minute. So horizontal scale is more important than vertical scale.
Per request we need a DB access either for storing an URL pair when an original URL is shortened or for reading the original URL based on the short URL for the redirect. We must ensure enough DB connections are available as this might be more likely to become a bottleneck than serving the requests as such. For the redirect case we should think about introducing a cache to minimize the no. of DB accesses.
Object: ShortURL
Methods:
The main DB table is basically a key value pair with the short URL as primary key and the original URL as value. As the redirect case will happen more often the short URL as key makes sense to allow optimal read performance.
We need a server who hosts the Client web pages and the URL shortening service. In between shall be a load balancer to balance the request load and implement basic security features like DOS prevention etc.
As persistence of the short URL matching the original URL we need a database. A Cache is also recommended to minimize DB load for the redirect case and increase request performance.
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?