![]() If we use the MD5 algorithm as our hash function, it will produce a 128-bit hash value. To generate a unique short URL, we can compute it using the unique hash (MD5, SHA256, etc.) of the original URL and then encode it using base62. Let's stick with 7 because even if we consumed 1000 keys per second, it would take 111 years to run out! Encoding However, the point of this system is to keep our URL as short as possible. The longer our key, the more URLs we have, and the less we have to worry about our system ever running out. Now, the question arises: what should be the length of the short URL generated to cater to 60 billion requests? Let us find out. What is the minimum length of the shortened URL to represent 60 billion URLs? We will use (a-z, A-Z, 0-9) to encode our URLs, which leads us to use base62 encoding. The total storage requirement would be = 60 billion * 200 bytes = 12TB. Now, let's assume the average URL length to be 120 characters (120 bytes), and we add 80 more bytes to store the information about the URL. Then, the number of URLs we will be storing would be = 500 million * 10 * 12 = 60 billion URLs. Storage Estimation: Let's assume that we are willing to store our data (short URL + long URL) for ten years. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |