Optional:
Shorten:
POST /shorten
{
"long_url": url,
"alias": optional str,
"time_to_expire": optional time
}
-> short_code: str
Redirect:
GET /{short_code}
-> 302 temporary redirection to long url
-> 404 not found
In the database we store the short/long url.
Each entry would be:
We have a client, a server, and a database in our design. The client send the requests to the servers, the server processes the requests, query the database and update the entries.
Shortening:
Redirect:
Cache can be a Redis, with LRU eviction policy.
Database can be any database.
Server can be horizontally scaled, we need a load balancer
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?