1.creating short Url approximate 200 per second.
2. Reading the short url and redirecting to long url 20000 per second
3. Short url length will be 8 characters
4. Only alphanumeric characters in short url
5. Logging and analytics is required
6. Expecting of expiry time of short url 1 year. After that we will be soft deleting the short url
1. Alert system if api fails down
2. Use Grafana. Newrelic to monitor the system.
3. System should be 99.99% availability by using redundancy and fail over mechanisms
4. Latency should be less than 10 milliseconds for read operations and write can be with in 10 seconds.
5. Database might required sharing because number of records too high.
6. Security of create url and get url api should be ssl
Short url = 200 per second
Per day = 200 * 60 * 60 * 24 = approximate 17.2 millions records
Per year = 6300 millions records
Each short url size would be 8 characters would be 8 bytes
Long url = 100 bytes
Created time = 10 bytes
Expiration time = 10 bytes
Meta data + UUId = 30 bytes
Approximate take 1 short url document will take 256 bytes
Per day data storage = 17 millions * 256= approximate 4.5gb
Per year data storage = 4.5 gb * 365 = 1.44 TB
Post api /{version}/short-url
Request body: {
"url" : String
"expiry_time" : Date format
"userId": Spring
}
Response :
Status code : 400
{
status_code : 400
"message": "url already exists"
"data":{
"shortUrl" : null
}
}
Status code : 200
{
status_code : 200
"message": ""
"data":{
"shortUrl" : String
}
}
Get Api {version}/expand/{short-url}
Response : {
"originalUrl" : String
}
Defining the system data model early on will clarify how data will flow among different components of the system. Also you could draw an ER diagram using the diagramming tool to enhance your design...
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...
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?