Given long url -> return shortened url
Given shortened url -> redirect to original long url
High availability: The url shortener service could run properly even some exception happens.
High scalability: The system should be highly scalable to be able to handle high volume of data
High performant: The system should perform high throughput and low latency
1. Traffic volume
Total requests : 100 million * 10 = 1 billion requests per day
2. How long is the shortened url?
As short as possible
3. What characters are allowed in the shortened url?
A-Z a-z 0-9
4.Write operation per second: 1 billion / 24 /3600 =~ 11600
5. Read operation:
Total storage for 10 years is 100 bytes * 3.65 trillion is 365 PB
Post:
/api/v1/data/shorten
request payload:
{longUrl: long url string}
return: shorten url
Get:
/api/v1/shortUrl
return: long url
Apprently, this is a read heavy system, so the relational database is the better option. However, due to this high volume of request per second, even we can scale the relational database horizentally we still may suffer from the distributed transactions, so I prefer the highly scalable and highly available non-relational database instead, for example, cassandra.
We also need Redis to be the cache center sit between database and applications to reduce the pressure for the database and speed up the processing time, the cache strategy we can use cache-aside for simplicity, and use LRU for the expiring strategy to evit the less frequently used data
Design:
Id: 123
shortUrl: tinyUrl
longUrl: xxxx/xxxx/xxxx

Short url generation flow:
Short url redirect flow:
We can use bloom filter to check whether url is not exist in the database to further reduce the pressure of the database
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...
Service design:
Hash + collision resolution
Cache design:
we can use hash structure of Redis to store it, key is shorten url, value is long url