The token generation is covered below, after the high-level design section.īuilding Blocks of a Scalable Architecture. If we require a larger range, then setting the token length to 8 characters gives us a larger set, which comes to around 2 trillion (we can build a service possibly with almost all URLs in the world! ). Token Lengthįrom the above table, we can choose the length of our token to be 7 characters long, which can accommodate more than 78 billion unique tokens. The number of unique tokens that can be generated using various token lengths are shown below. To be URL safe, consider smaller case characters a-z and numbers from 0-9, we have a total character set of 36 character set. While designing the URL shortening service, we pay close attention to the length of the token and the characters it contains. The length of a token typically varies from 6-9 characters. Tokens are alphanumeric strings and act as identifiers to the actual long URL. Short URLsĪ typical short URL could be something like this, where ts.dz is a short domain for a particular application, service, or company, and the last part in the URL qp7h3zi is a unique, random identifier. The identifiers should be short enough to fit in the URL with an acceptable character set. ![]() The interesting part of the problem is generating unique, random identifiers for these long URLs. ![]() ![]() Please pause here and think about how you could design a system to generate an infinite number of short URLs for possibly all long URLs in the world. The need for shortened URLs arises when long URLs have to be shared for various purposes, like sharing links via SMSs, Emails, media types, like Twitter or WhatsApp, etc.Ī URL shortening service might sound like a simple service at first, but it poses a very interesting and challenging engineering problem. Typically, a long URL is a system-generated URL, usually containing multiple query parameters that may be encrypted/encoded to mask those parameters.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |