4 ms·
Performance of URL shorteners
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!
- trickjarrett 18y agoHow did you make your time tests?
- sanj 18y agoIt 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 18y agoI 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 18y ago100 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.
- sanj 18y agoAre there others that should be tested?
- thorax 18y agohttp://ri.ms 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://tr.im/ http://metamark.net/ http://metamark.net/
- thorax 18y agoOne 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 http://en.wikipedia.org/wiki/TinyURL#Early_abuses