September 6, 2009

How TinyURL work's !!

The service tinyurl accepts a long URL string (presumably the location of a web document or something else such) and creates a permanent shortcut for it.


to




The question is, how does the service create such a small shortcut for any of the virtually thousands of web URLs out there? Does it compress the URL? Does it store it somewhere?

A little judicious observation can reveal some of the little "secrets" behind this service. The first "obvious fact" is that the shortcut has always a fixed length. In fact, the effective length looks as if it is exactly six (last 6 characters). The second "obvious fact" is that the shortcut consists of only small-caps letters and the digits 0-9.

The above observations quickly lead to the conclusion that the number of all possible configurations of the second part of the shortcut string is bounded above by 366 = (26 letters + 10 digits)6. This number equals 2176782336 and is close to maxlongint (or max int in Java).

Therefore, all one has to do to create such a service is have a Java program with the following (pseudo) declaration:

T=array[1..int] of string;

Considering the maximum length of any string allocated to be 255, an upper bound for the memory of this table will then be 2147483647 * 255 = 547608329985 bytes. That's roughly 510 Gigabytes of storage space and is doable with large capacity drives.

so, TinyURL variations are not limitless but they are close !!!

will have more posts regarding URL shortening services soon :)

0 comments:

About This Blog

Lorem Ipsum

  © Blogger templates Newspaper III by Ourblogtemplates.com 2008

Back to TOP