This is taken from Wikipedia..
"
Each time a visitor visits a page with an AdSense tag, a piece of JavaScript writes an iframe tag, whose src attribute includes the URL of the page. Google's servers use a cache of the page for the URL or the keywords in the URL itself to determine a set of high-value keywords. (Some of the details are described in the AdSense patent.) If keywords have been cached already, ads are served for those keywords based on the AdWords bidding system.
The storage requirements of an AdSense system are stunningly modest. If each URL has just 8 "high-value" keywords, each represented by a single 32-bit number, then the keywords for each URL could be represented with just 32 bytes. The high value keywords of 4 billion URLs could be stored in 128GB, which would cost only $100 (circa 2006). 400 billion URLs or 100 drives (for a redundancy of 100) would require only $10,000 in storage costs.
AdSense serves a very large number of pages each day. If each day around 1B people saw 10 AdSense impressions (or 100M people saw 100 AdSense impressions), then AdSense would serve around 10B requests/day, or 115,741 requests/sec. If one machine can serve 20 reqs/second (seek times to read a random 4096-byte location on a drive allow for bursts of well over 100 reqs/second), then Google would require 5,787 servers to serve these 10B reqs/day. If each of these servers were hosted at a cost of $100/month, then it would cost $579K/month to run the adservers needed.
Suppose these 10B impressions/day generated clicks at a clickthrough rate of .3% and an average CPC of $.10. Then each day Google would receive 30M clicks/day (347 clicks/sec), generating $3M/day ($34.77/sec), or 900M clicks/month, generating $90M/month."Can you follow this???
Here's the link.