Give a long url, return the short URL
Given a short URL, get the long URL and redirect to the website
scalable, available, robust
1 billion searches per day.
10% new URLs every day are new.
Read QPS=1000 URLs/sec
Peak Read QPS=2*1000
Data storage: 1 URL=500KB
10 million new URLs every day = 500*10million KB per day
=5TB per day.
2PB storage space to store URLs for 1 year
POST/v1/url (params: longURL)
response: shortened URL
GET/v1/url (params shortURL)
response: longURL
Hashmap with longURL as key and shortURL as value and vice versa.
There are various methods to undertake URL shortening.
We will try to convert the URL in which the shortened URL will only contain alpha numeric letters.
Possibilities of conversion: base 62, SHA, MD-5 hash
We will use base62 as it suites our requirement.
total URLs that can be stored: 62^7 if we are planning to make a hash value of length 7.
This will be able to store all possible conversions without collision.
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?