List functional requirements for the system (Ask the chat bot for hints if stuck.)...
List non-functional requirements for the system...
For Data storage:
So the total data storage is around 11 GB per day
For bandwidth estimates, let's assume we have 100 million DAUs and 100 million URLs visited per day. So the bandwidth is around 100M * (110bytes) /86400 = 110kb/s
URL mappring:
Key: Long URL
Value: shortened URL, so here we use Mongo DB, as it's high performance and scalability
The shortening request will firstly go to load balancer and then the load balancer will decide which server to go to, and then the URL shortening service will encode the URL and then add the shortened URL to database and cache.
The redirecting request will firstly go to load balancer and then served by retrieving URL service, then it will try to get the corresponding URL in the cache, if not found, then it will do the data base query.
For the Mongo DB database structure, we use key-value store form like, in this way, the shorten URL can find the corresponding long URL very quickly. And we will do sharding by its Id, to minimizing the hot-spot problem.
For the Cache, we will use Redis, and use LFU as its eviction policy to try to reduce the load to database
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?