![]() Let’s assume 100:1 ratio between read and write.If we assume that we would have 500M new URLs shortenings per month.We can expect (100 * 500M => 50B) redirections during the same time.What would be Queries Per Second (QPS) for our system?.New URLs shortenings per second: 500 million / (30 days * 24 hours * 3600 seconds) ~= 200 URLs/s.URLs redirections per second: 50 billion / (30 days * 24 hours * 3600 sec) ~= 190000 URLs/s.Since we expect to have 500M new URLs every month and if we would be keeping these objects for five years.Total number of objects we will be storing will be: 500 million * 5 years * 12 months = 30 Billion.Let’s assume that each object we are storing can be of 500 bytes (just a ballpark, we will dig into it later).Total storage we will need be: 30 billion * 500 bytes = 15 TB.For write requests, we expect 200 new URLs/second the total incoming data per second: 200 * 500 bytes = 100 KB/s.For read requests, we expect ~ 19K URLs /second redirections, total outgoing data per second: 19K * 500 bytes ~= 9 MB/s.If we want to cache some of the hot URLs that are frequently accessed, how much memory would we need to store them?. ![]() If we follow the 80-20 rule, meaning 20% of URLs generating 80% of traffic, we would like to cache these 20% hot URLs.Since we have 19K requests/second, we would be getting requests: 19K * 3600 seconds * 24 hours ~= 1.7 billion requests/day.To cache 20% of these requests, we would need memory: 0.2 * 1.7 billion * 500 bytes ~= 170GB.Assuming 500 million new URLs per month and 100:1 read:write ratio.Following is the summary of the high level estimates for our service.Once we’ve finalized the requirements, it’s always a good idea to define the system APIs. This would explicitly state what is expected from the system. We can have SOAP or REST APIs to expose the functionality of our service.Following could be the definitions of the APIs for creating and deleting URLs.url_key is a string representing the shortened URL to be retrieved.A successful deletion returns “URL Removed”.
0 Comments
Leave a Reply. |