Tech●●●●●Difficulty 4 of 5

How can a search engine answer billions of queries in a blink?

In 1994 a web search engine got about 1,500 queries a day. By 2012 Google was answering over 3.5 billion.

▶ Start the story

A search engine answers billions of queries by never asking one machine to do it alone. Its index is cut into pieces called , each shard is copied onto several servers, and every question is sent to many machines at once before their answers are merged. The engine is part of a system that can span many around the world.

The growth has been dizzying. In early 1994 the World Wide Web Worm, an early search engine, got about 1,500 queries a day. By November 1997 AltaVista claimed roughly 20 million a day. By 2012 Google was handling more than 3.5 billion searches per day, from an index of over 30 trillion pages.

A 2003 report showed how Google kept up. At peak it served about 1,000 queries a second, and instead of expensive supercomputers it used a cluster of some 15,000 ordinary PCs, with software written to cope with the ones that failed. Its index was split by document into , and each shard was copied onto several servers; as traffic grew, Google added more copies so that more machines could answer at once. A web server sends each query out to the index servers, merges and ranks what comes back, then adds page summaries, spelling suggestions and ads.

Many machines, one question
  1. Step 1: A query arrives

    A web server takes charge of it

  2. Step 2: Fan out

    Sent to index servers, each holding some

  3. Step 3: Search in parallel

    Every slice is searched at the same time

  4. Step 4: Merge and rank

    Results combined, ranked and summarised

  5. Step 5: Finish the page

    Spelling suggestions and ads are added

Speed sometimes means settling for less. Google's 1998 prototype stopped searching once it had found 40,000 matching documents, to put a limit on response time, even though that might return results. Disks were the other enemy: a took about 10 milliseconds, and in early 2001 Google moved its whole index into memory, cutting waiting times sharply. All of this costs energy: in 2009 Google claimed a single search used about 1 kilojoule, enough to warm a litre of water by about a quarter of a degree.

Quiz me

0/3

  1. 1.Why did Google keep several copies of each shard of its index?
  2. 2.Why did Google's 1998 prototype stop after finding 40,000 matches?
  3. 3.Why did the early Google design avoid disk seeks whenever possible?

Recap

Split the index into shards, copy each shard to share the load and survive failures, ask them all at once, and accept a very good answer fast.

💡 A trick to remember it · A thousand librarians each check their own shelf at the same moment, with a stand-in on every shelf in case one is off sick.

Surprising fact · In 2003 Google handled about 1,000 queries a second at peak on some 15,000 ordinary PCs instead of supercomputers.

Sources (5)

No source, no claim. Every fact in this lesson (20 claims) cites at least one of these.

  1. [1]The Anatomy of a Large-Scale Hypertextual Web Search Engine · Stanford University (Brin and Page)
  2. [2]Google Search · Wikipedia
  3. [3]Sharding · Wikipedia
  4. [4]Web search engine · Wikipedia
  5. [5]Google data centers · Wikipedia
More lessons in 💻 Tech (3) See all tech lessons →

One more light on your map.

Get one lesson like this every day, about the things you love. Free, in two or five minutes.

Get the share card for this lesson ↗