

Ask HN: opensource solution for URL shorter? - jacktang

I always want to know what's the challenge of shorting long URL.
======
digamber_kamat
Since you just want to know the challenges and are not really concerned about
"whether url shortening is a good thing" I will put one challenge here. I am
sure there will be many more.

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.

~~~
jacktang
I start hacking by erlang and mnesia database, so I might not face your mysql
issues.

> 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.

------
dotcoma
is it something interesting to do for a hacker?

who pays the bandwidth bills?

what do you get out of it?

