We need to have mapping between short url and long url. Short url maybe size of the 20 bytes, long 100 bytes, total 120 bytes. We may have 20 million users, each generating 10 links per day.
So it's, 20 000 000 * 10 * 120 = 24 000 000 000 = 24 Gigabytes per day, after 1 month, 24 * 30, 720 GB per month increase.
In case of the RPS, it's 2000 request per seconds. So we need around, 100 machines to serve API.
`POST: domain.com/shorten -> shortUrl` with requestBody: {url: url}
`GET: domain.com/url` it will return NOT_FOUND, or redirect code with longeurl
We are going to use restful api specifications.
url: string
shortUrl: string
userUrl: string (optional to keep track in case we want to make this authorized only)
We are going to have servers with loadbalancer. Where will have algorithm to generate shortUrl. It can using incremental counter, which is later converted to the base64. For that need distributed counter.
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?