12

Time and again when I search for a topic on Google, Google returns me the results and also prints out some stats like

"Results 1 - 10 of about 8,850,000 for j2me. (0.24 seconds)"

I notice that the seconds taken by Google to serve the results are in fraction of a second range.

How does Google serve pages so fast, what kind of database optimization tricks has it used at its end?

Neil Aitken
  • 7,856
  • 3
  • 41
  • 40
Kevin Boyd
  • 12,121
  • 28
  • 86
  • 128
  • 5
    I guess SO users could benefit from this answer. – Kevin Boyd Aug 19 '09 at 09:59
  • Actually on the second search it's about 0.1 secs! Because they must be caching the search criteria for some time. If somebody else around the world has searched for your criteria it would be 0.1 sec the first time as well! To try this: type 'map' & search and you see that this is always about 0.1 secs because it's constantly searched by users. But if you search for random text like 'asdasddsfdsfsf' it would take 0.2 -0.5 secs. – user44298 Nov 19 '10 at 18:26

2 Answers2

10

I think the main reason for the frontend performance are:

  • Each request is distributed to a series of machines in parallel (I have read somewhere that each query hits around 12 machines), probably a single machines gathers the responses from these machines
  • All index data are held in RAM. With index data, I mean the term vocabulary and the postings list index and in the case of Google probably a lot more indexes e.g. for spelling corrections. Even with a single disk I/O somewhere the latency of the disk seek prevents such a performance.

Googles Map/Reduce, GFS are great tools for background processing, but they have nothing to do with the frontend performance.

dmeister
  • 34,704
  • 19
  • 73
  • 95
  • Well sir, i think you are missing one point overhere. Google not only returns the list of URLs but infact a ranked list of them. So, some kind of computations must be happening once a query hits one of those 12 machines. And considering that personalization is also carried out and that Google has user base of Billions, i would place my bet on GFS and MapReduce being used on the list of URLs retrieved from index at each one of those 12 machines to calculate the relevance of each retrieved url w.r.t the query. And then offcourse you can sort on those relevance numbers to return the ranked list – Shatu Dec 03 '12 at 21:24
  • Sir, I still bet against. MapReduce is by design a batch processing system with a pretty high latency. In either case, this are (educated) guesses. I don't know for sure. – dmeister Dec 04 '12 at 06:29
  • `All index data are held in RAM`. This is plain silly. – michaelmeyer Aug 29 '14 at 18:37
  • @michaelmeyer Apparently Google switched to in-RAM indexes in 2001: https://en.wikipedia.org/wiki/Google_Data_Centers#Index I still don't know how it's possible that Google has enough RAM to store basically the entire contents of the public-facing internet. Wow. – Ryan May 10 '18 at 13:20
5

Map and Reduce + huge distributed datacenter.

  • 1
    MapReduce is unlikely to be the key for fast real-time calculation. When submitting a job, the latency of Hadoop is typically more than a minute due to its design nature. – user1036719 Oct 04 '13 at 23:04