

Performance of URL shorteners - sanj

Hiya.  I'm answering my own question.  Being disappointed with how slowly TinyURL ran, I asked HN about the performance of others:<p>http://news.ycombinator.com/item?id=421552<p>I just spent a few minutes timing alternatives:<p>TinyURL: 0.44s/req<p>bit.ly:  0.19s/req<p>is.gd:   0.07s/req<p>That's a pretty big spread!
======
thorax
One of the reasons is.gd is fast is because it uses sequential URLs for each
request, so it doesn't have to do multiple collision tests. tinyurl used to do
this eons ago, but stopped because of abuses (actually somewhat NSFW):
<http://en.wikipedia.org/wiki/TinyURL#Early_abuses>

------
sanj
Are there others that should be tested?

~~~
thorax
<http://ri.ms> but we didn't optimize the server as much as the algorithm for
creating a url.

Depending on algorithm, some of these will sites vary their performance based
on database size. So it might be that is.gd is just not as large as the others
and/or has less traffic.

Edit: There're also others like:

<http://tr.im/>

<http://metamark.net/>

------
trickjarrett
How did you make your time tests?

~~~
sanj
It ain't pretty, but:

require 'mechanize'

    
    
      class Tinyurl 
      def self.make_tiny(big_url)
        url = "http://tinyurl.com/api-create.php?url=#{big_url}"
        agent = WWW::Mechanize.new
        agent.user_agent_alias = 'Mac Safari'
        results = agent.get(url)
        return results.body
      end
    
      def self.test(base="http://www.google.com?q=sanjay", iterations = 10)
        t=Time.now
        (0..iterations).to_a.each do |i|
          puts make_tiny("#{base}#{i}:#{rand(100000000)}")
        end
        puts Time.now-t
      end
     end
    
     Tinyurl.test

~~~
mncaudill
I could be wrong as I'm not that familiar with Ruby, but I imagine to get more
meaningful results (not saying that the results will be different), I would
run the tests many more times than 10, as well as not printing to stdout
inside of your testing loop.

~~~
sanj
100 iterations instead of 10, removed puts:

TinyURL: 0.43s/req

bit.ly: 0.22s/req

is.gd: 0.05s/req

That's close enough to my original values to not matter. It appears that the
time is all spent waiting for the site to return.

