Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Performance of URL shorteners
7 points by sanj on Jan 6, 2009 | hide | past | favorite | 7 comments
Hiya. I'm answering my own question. Being disappointed with how slowly TinyURL ran, I asked HN about the performance of others:

http://news.ycombinator.com/item?id=421552

I just spent a few minutes timing alternatives:

TinyURL: 0.44s/req

bit.ly: 0.19s/req

is.gd: 0.07s/req

That's a pretty big spread!



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


Are there others that should be tested?


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/


How did you make your time tests?


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


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.


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.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: