At a higher level there is nothing difficult. you have to only maintain a table with shortened code to actual url mapping and then use HTTP redirection requests to redirect the URL.
But what should be the length of that shortened code ?
Should it be fixed or variable ?
How do you generate that shortened code?
Can the same URL have different codes?
Should we generate the code based on some hash stuff (in such a case looking up for duplicates will be simple) or should we just increment the last generated code ?
Once this is done let us say we create a table in mysql with code => URL mapping. The able type is MyISAM which supports only table level locking
If there happen to more writes on table than reads. The read operation becomes slow. Hence the table type needs to be InnoDB which supports row level locking.
These issues might be corner issues but they do exist and sometimes they can matter as well.
> How do you generate that shortened code? Can the same URL have different codes?
It depends, I will assign random hash to the specified URL.
who pays the bandwidth bills?
what do you get out of it?