Thursday, August 17, 2006

Google search results - link tracking costs 90 Gigabytes / day

I spent a few minutes, together with Eran, looking at the method that Google uses to track which links are clicked in the Google search results page. I figured they must be doing this, since it sounds like an essential bit of information, and of course they do that.

The mechanics are simple, and very well implemented - the generated links in the search results have a onmousedown JavaScript function (named clk) attached to them. When a link is clicked this JavaScript bit is run. Essentially what it does is use the JavaScript Image object (one of the oldest tricks in the JavaScript "book") to send a request to the Google web site, with the clicked link information:

function clk(url,oi,cad,ct,cd,sg) {
new Image().src="/url?sa=T"+oi_param+cad_param+"&ct="+e(ct)+"&cd="+e(cd)+u+"&ei=jwbkRLWWGYfa2wKN1uRj"+sg;

I was surprised though to find in that otherwise-sparkling-clean Google implementation a bunch of additional JavaScript functions which appears to be never used, like:

function ss(w,id){window.status=w;return true;}
function cs(){window.status='';} var bdg = 0;
function sb() {bdg = 1;}
function ga(o,e)
function anbc(id)

A quick count of the bits shows that the unused JavaScript code amounts to about 1K in size, per search results page. Assuming 91 million searches per day, this means unnecessary waste of 80-90 Gigabytes (depending on how you count MB - the right way or the Western Digital way :) ) of bandwidth, every day.

It's a good thing that bandwidth is so cheap. If Google was running on GoDaddy, they'd consumed their entire $10/month 500GB bandwidth limit in 6 days :)

And no, please don't count how much bandwidth we waste on unnecessary JS in the Yedda pages, I can tell you right away it's quite a bit. Functionality first, optimizations later!

Technorati : , , , , , : , , , , ,


Eran Sandler said...

A few minor details updates:
GoDaddy now offers 1000Gb per month for trasfer for $6.99 per month (and its even less if you pre pay).

The 80-90Gb does not include GZIP compression (which is probably enabled on Google web servers) so it can by up to 50% less (which is only a staggering 40-45Gb per day)

YanivG said...

Ah... so *that* is why they call it OCD.. :)