Distributed Crawling and Connectivity Servers

Crawling the web with many machines. Dividing hosts among crawler nodes, exchanging URLs, keeping duplicate detection consistent, and handing the crawl to distributed indexing, followed by connectivity servers, which store the web's link graph compactly enough to answer link queries quickly. Worked problems, including the course text's exercises on host partitioning and reference encoding.

A distributed crawler assigns each host to one node, which keeps politeness and the host's caches local; nodes exchange the links that belong to one another, and content fingerprints are partitioned by value, since copies cross hosts. Assigning hosts by hash modulo $n$ moves a fraction $n/(n+1)$ of them when a node joins, while consistent hashing moves an expected $1/(n+1)$, the least possible. With 100 points per node the busiest of 4 nodes carried 1.08 times an even share, against 2.10 with one point (medians over 30 placements). A connectivity server stores the link graph for in-link and out-link queries; locality, gaps and references to similar lists bring it to as few as 3 bits a link, the course text reports, instead of 64.

The course text gives the scale of the task: fetching a billion pages in a month-long crawl takes several hundred fetches a second (Manning, Raghavan, and Schütze, 2008, §20.2), since $10^9$ pages in 30 days is 386 a second. Suppose one machine running the crawler architecture described earlier sustains 300 a second. Fetching ten billion pages once would then take 386 days, about a year, and a search engine must also revisit pages to keep them fresh. Which of many machines should fetch which page, and what must the machines tell each other? In brief, each machine takes the pages of a fixed set of hosts, and the machines exchange the links and the content fingerprints that belong to one another.

A distributed crawler runs the crawl loop on many machines, called nodes, often in several data centers. The crawl also discovers the link graph, and storing it for fast lookup is the job of a connectivity server.

Here is the route. First we divide hosts among nodes, comparing modular and consistent hashing. Then we follow what nodes must exchange, and hand the crawl to indexing. Then we compress the link graph until it fits in memory. Worked problems close the article.

Dividing the work

The natural unit of division is the host. Each crawler node is made responsible for a set of hosts, and it fetches every URL on those hosts and no others. Croft, Metzler, and Strohman (2010, §3.2.7) give two reasons for hashing the host rather than the whole URL.

  • Politeness stays local. All requests to a host come from one node, which can enforce the delay between them without consulting the others.
  • Fewer links cross between nodes. Pages on a host link mostly to other pages on the same host, and those links stay with the node that found them.

A further benefit is that the node that crawls a host also keeps its robots.txt rules and DNS results in its caches.

A simple assignment hashes the host name and takes the result modulo the number of nodes. Simple modular hashing reassigns almost every host when a node is added or fails. UbiCrawler (Boldi, Codenotti, Santini, and Vigna, 2004) used consistent hashing instead. It moves only the hosts of a node that leaves, or the hosts taken over by a node that joins. Geographic distribution can refine the assignment, giving each data center the hosts that are close to it on the network.

Why modular hashing moves almost everything

Example (four nodes become five). A crawl grows from 4 nodes to 5, with hosts assigned by hash modulo the number of nodes. To give the new node an equal share, a fifth of the hosts must move, but four fifths actually move. Suppose a host name hashes to the integer $h$. The host stays where it was only if $h \bmod 4 = h \bmod 5$. Both remainders are determined by $h \bmod 20$, and of the 20 possible values of $h \bmod 20$, only 0, 1, 2 and 3 give equal remainders. So a fraction $4/20 = 1/5$ of hosts stay and $4/5$ move. On 100,000 synthetic host names, 0.801 moved.

The general statement is that going from $n$ to $n+1$ nodes moves a fraction $n/(n+1)$ of all hosts, which approaches all of them as the crawl grows. The proof is the same count. Since $n$ and $n+1$ have no common factor, the pair of remainders $(h \bmod n,\ h \bmod (n+1))$ is determined by $h \bmod n(n+1)$, and each pair occurs for exactly one of those $n(n+1)$ values (the Chinese remainder theorem, which proves this correspondence for relatively prime moduli). The pairs with two equal remainders are $(0,0), (1,1), \dots, (n-1, n-1)$, which is $n$ pairs. So $n$ of the $n(n+1)$ values stay, a fraction $1/(n+1)$, and the fraction $n/(n+1)$ moves, provided the hash values are spread evenly over the residues.

A move is expensive. The new node has no robots.txt rules or DNS results cached for the host and no record of when it was last contacted. The host's URLs in the old node's frontier must all be sent over. An assignment that moves only the fifth that must move would avoid most of that cost, and one exists.

Consistent hashing

Consistent hashing was introduced by Karger, Lehman, Leighton, Levine, Lewin, and Panigrahy (1997) for distributing web caches. In their words, it is a hash function that "changes minimally as the range of the function changes". The idea: put hosts and nodes on one circle and give each host to the next node along, so a new node takes hosts only from one neighbor. The usual construction:

  1. Hash each node's name to a point on a circle, for example a 32-bit value read as a fraction of a full turn.
  2. Hash each host name to a point on the same circle.
  3. Assign each host to the first node found by moving clockwise from the host's point.

Each node owns the arc that ends at its own point. When a node joins, it takes over only part of one arc: the hosts between its point and the previous node's point. Every other host stays put. When a node leaves, only its own hosts move, to the next node clockwise.

How many hosts the new node takes follows from symmetry. With $n + 1$ nodes placed at independent, uniformly random points, no node is distinguished from the others, so each owns the same expected share of the circle, and the shares sum to 1. Each share is therefore $1/(n+1)$ on average. The hosts that move are exactly the new node's hosts, so the expected fraction that moves is $1/(n+1)$, the least that gives the new node an equal share. For 4 nodes becoming 5 that is one fifth. A particular placement can give much more or less than the average, as the next table shows.

Twelve hosts and four nodes, A to D, placed on a circle by hashing their names. Each host belongs to the first node clockwise from it (letters in parentheses). Notice that when node E joins, it takes only the two hosts on the arc just before it, cnn.com and unc.edu, from node C, and the other ten hosts keep their nodes. With modular hashing, going from 4 to 5 nodes moved 10 of these 12 hosts.
Twelve hosts and four nodes, A to D, placed on a circle by hashing their names. Each host belongs to the first node clockwise from it (letters in parentheses). Notice that when node E joins, it takes only the two hosts on the arc just before it, cnn.com and unc.edu, from node C, and the other ten hosts keep their nodes. With modular hashing, going from 4 to 5 nodes moved 10 of these 12 hosts.

The basic construction does not also divide the work evenly, as the figure shows. With one point per node, the arcs have very unequal lengths: node A's arc is so short that it owns none of the twelve hosts, while D owns five. The standard remedy is to give each node many points on the circle, called virtual nodes, so that each node's share is the sum of many short arcs and evens out. A simulation with 100,000 synthetic host names, over 30 random placements of the nodes, gives:

Points per node Hosts moved, 4 to 5 nodes Load of the busiest of 4 nodes
1 0.182 (0.066 to 0.327) 2.10 (1.88 to 2.84) times an even share
100 0.204 (0.187 to 0.212) 1.08 (1.06 to 1.11) times an even share
Modular hashing 0.801 1.005 times an even share

Each entry is the median over the 30 placements, with the middle half of the placements in parentheses (rounded to three places, or two for loads). Both forms of consistent hashing move about the ideal fifth of the hosts. With one point per node, though, the amount moved varies widely with the placement, and the busiest node typically carries about twice its share. With 100 points per node it carries only about 8 percent more. Modular hashing balances load almost perfectly and moves four fifths of the hosts. In every run, every host that moved under consistent hashing moved to the new node, as the construction guarantees.

Exchanging URLs

A node parsing a page finds links to hosts it is not responsible for. Manning, Raghavan, and Schütze (2008, §20.2.1) add a host splitter to the crawler, after the URL filter. Each link is sent to the node that owns its host, and links received from other nodes enter the local duplicate URL elimination and frontier like any others.

The exchange would be expensive if every link were sent separately, but two properties keep it manageable. First, as noted above, many of the links a node finds are its own. In the crawl of this site, only 34 of 1,640 links pointed elsewhere, though a single site is an extreme case. Second, the links that must be sent can be batched. Links to very popular pages, which appear on many hosts, can be filtered locally with a cache of URLs known to be already seen, so they are not sent repeatedly.

Duplicate content across nodes

Duplicate URL elimination partitions naturally by host, since a URL belongs to one host. The "content seen?" test does not. Two copies of a page can live on different hosts, and so on different nodes.

The fingerprints of fetched pages are therefore partitioned by the fingerprint itself, not by host. Each node sends the fingerprint of every page it fetches to the node responsible for that fingerprint, which answers whether it has been seen before. The responsible node can be chosen, for example, by taking the fingerprint modulo the number of nodes (Manning, Raghavan, and Schütze, 2008, §20.2.1). Most of these tests are therefore remote calls, though lookups can be batched. For near-duplicates, the sketch values can be partitioned the same way.

From crawl to index

A distributed crawl produces its pages spread across many machines, and indexing them is distributed too. Index construction describes building an inverted index with MapReduce. In it, parsers process splits of the collection and inverters gather the postings for ranges of terms. The finished index is then partitioned for searching, almost always by document, as search at scale explains.

Connectivity servers

A crawl discovers not only pages but the links between them, and the link graph is valuable in itself. PageRank, HITS and other link analysis methods are computed from it, anchor text is gathered along it, and link patterns help detect spam. Many applications need two kinds of query answered quickly:

  • out-links: which pages does page $p$ link to?
  • in-links: which pages link to page $p$?

A connectivity server answers them (Bharat, Broder, Henzinger, Kumar, and Venkatasubramanian, 1998). It stores two adjacency lists for every page, its out-links and its in-links, with each page identified by an integer rather than its URL. A crawl observes only out-links, since a page lists the pages it links to. The in-link lists are obtained by inverting them: every pair (source, target) is re-sorted by target, the same step that turns documents' term lists into postings lists in index construction. The difficulty is size. Manning, Raghavan, and Schütze (2008, §20.4) take a web of four billion pages with ten links each. Storing both ends of each link as 32-bit page identifiers needs $4 \times 10^9 \times 10 \times 8$ bytes, about 320 gigabytes. The lists should fit in memory for fast access, so they must be compressed.

The web's links are not random, and the compression methods exploit three regularities of the web graph (Manning, Raghavan, and Schütze, 2008, §20.4):

  • Locality. Many links point to pages on the same host. If pages are numbered in lexicographic order of their URLs, pages on the same host receive nearby numbers. A page's out-links are then often close to its own number.
  • Gaps. As with postings lists in index compression, a sorted adjacency list can be stored as the differences between successive identifiers. These are small and encode in few bits.
  • Similarity. Pages on the same host often have nearly identical link lists, since they share navigation menus. A list can be encoded as a reference to a similar, earlier list plus the differences.

A small example shows the first two working together. Suppose pages are numbered in URL order and page 1001 links to pages 1000, 1002, 1003, 1010, 1011, 1050 and 2040. Most of them are on its own host and so numbered nearby. Stored as 32-bit identifiers, the list takes $7 \times 4 = 28$ bytes. Stored as the first identifier followed by the gaps between successive ones, it is

$$1000,\ 2,\ 1,\ 7,\ 1,\ 39,\ 990.$$

Variable byte encoding uses 7 bits of each byte for the number, so every value below 128 fits in one byte and values up to 16,383 in two. The gaps 2, 1, 7, 1 and 39 take one byte each, and 1000 and 990 take two. That is 9 bytes in all, about a third of the original. Postings lists in current search engines use codes that compress a whole run of gaps at once instead of one gap at a time; modern postings compression works them bit by bit, and a sorted adjacency list, being a sorted list of integers too, can be encoded the same way.

Example (links without locality). If the seven links instead pointed to random pages among the four billion, gap encoding would no longer save space. The gaps would be in the hundreds of millions, needing four or five bytes each. Over 30 random draws, the list took a median of 32 bytes, against 28 at a flat 32 bits. Locality is what makes the gaps small.

The third idea goes further. Suppose page 1004, on the same host, links to the same pages as page 1001 except 1050, and also to 1012. On its own, its list is $1000, 1002, 1003, 1010, 1011, 1012, 2040$, with gaps $1000, 2, 1, 7, 1, 1, 1028$, which again take 9 bytes. Stored by reference it needs four items:

  • which earlier row to copy, here the row 3 places back (page 1001);
  • how many of that row's entries to drop, here 1;
  • which one, here the sixth entry (1050);
  • the entries to add, here 1012, written as its distance of 8 from the page's own number 1004.

At one byte each that is 4 bytes in place of 9, and copying the row, dropping its sixth entry and inserting 1012 rebuilds the list exactly. The byte layout is ours, chosen to make the count concrete, and real systems pack these fields into bits. The course text's scheme looks for the prototype only among the seven preceding rows, so that the offset fits in 3 bits (Manning, Raghavan, and Schütze, 2008, §20.4). Problems 3 and 4 below take up the two questions that choice raises.

The Link Database (Randall, Stata, Wickremesinghe, and Wiener, 2002) and the WebGraph framework (Boldi and Vigna, 2004) combined these ideas. The course text reports that the combined techniques use as few as 3 bits per link on average, against the 64 of the plain representation. At 3 bits, the forty billion links of the example above take $4 \times 10^{10} \times 3 / 8$ bytes, or 15 gigabytes, where 320 were needed.

This site's link graph showed the same regularities on a small scale. When the site had 82 pages, it had 1,115 distinct links among them. Of these, 162 pointed to just two pages, the home page and the Academics page, which are linked from every page's navigation menu. Another 78 pointed to the CSC 790 course page. Every wiki article's out-link list contained the same few entries, exactly the redundancy that reference compression removes.

The hashing, gap-encoding and timing numbers in this article are computed by tools/experiments/crawling/host_assignment.py in the site repository, and the site measurements by sitecrawl.py in the same folder.

Worked problems

Problems 1, 2, 4 and 5 are Exercises 20.1, 20.2, 20.4 and 20.5 of the course text (Manning, Raghavan, and Schütze, 2008), restated in our words. Problems 3 and 6 are posed on this article's examples. The numbers are checked in host_assignment.py.

Problem 1 (Exercise 20.1). Why is it better to divide hosts among the nodes of a distributed crawler than to divide individual URLs?

There are three reasons, and each follows from something that is kept per host.

  • Politeness. The delay between requests to a host must be enforced by whoever sends the requests. If one node sends all of them, it enforces the delay from its own records. If a host's URLs were spread over several nodes, each would have to ask the others when the host was last contacted before every fetch.
  • Fewer links to exchange. Most links on a page point to the same host. With hosts as the unit, those links belong to the node that found them and are never sent. With URLs as the unit, a link would belong to another node with probability $(n-1)/n$ for $n$ nodes, whatever host it pointed to.
  • Caches. The robots.txt rules and the DNS result for a host are fetched once and kept by the node that crawls it. With URLs as the unit every node would fetch and store them for nearly every host.

Problem 2 (Exercise 20.2). Why should the host splitter come before duplicate URL elimination?

Because each node's set of URLs already seen covers only its own hosts. A link to a host owned by another node cannot be tested where it was found: the local set does not hold that host's URLs, so the test would pass every time and prove nothing. The link must first be sent to its owner, and the owner tests it against the one set that can answer. Placing the splitter first also keeps each node's set small, a share of the whole in proportion to its share of hosts, where testing before splitting would require every node to hold the URLs of every host.

Problem 3 (seven nodes from six). A crawl of 6 nodes assigns hosts by hash modulo 6 and adds a seventh node. What fraction of hosts moves under modular hashing, and what fraction under consistent hashing?

Under modular hashing a host stays only if $h \bmod 6 = h \bmod 7$. The two remainders are determined by $h \bmod 42$, and they are equal exactly for the six values 0 to 5. So $6/42 = 1/7$ of the hosts stay and $6/7 \approx 0.857$ move. On the 100,000 synthetic host names, 0.858 moved. Under consistent hashing the expected fraction is the new node's share, $1/7 \approx 0.143$. Modular hashing moves six times as many hosts as necessary, and the factor is $n$ in general, since $\frac{n/(n+1)}{1/(n+1)} = n$.

Problem 4 (Exercise 20.4). The scheme of the course text encodes a row by reference to one of the seven preceding rows, so that three bits name the row. Why seven and not eight, when three bits can name eight things?

Because one of the eight values is needed to say that there is no prototype. Some rows resemble none of their predecessors, for example the first row of each new site, and those are written out in full. The decoder must be told which case it is reading. With three bits, seven values name offsets 1 to 7 and the eighth means "no reference, the list follows". Using all eight values for offsets would need a separate flag bit on every row to mark the rows without a prototype.

Problem 5 (Exercise 20.5). Decoding a row may require decoding the row it refers to, and so on. Construct an example in which the number of levels of indirection grows linearly with the number of rows.

Let row 1 be the list $\{1\}$, written in full, and for each $i \ge 2$ let row $i$ be the list $\{1, 2, \dots, i\}$, encoded as "the same as the row at offset 1, with $i$ added". Each row differs from the one before by a single entry, so the encoder is right to choose it as prototype every time. To decode row $n$ the server must first decode row $n - 1$, which needs row $n - 2$, and so on down to row 1: $n - 1$ levels of indirection for row $n$, which the script confirms by decoding rows 1, 2, 5 and 8. The cost of answering a query grows with the position of the row.

The course text's remedy is a threshold of similarity: a row is coded by reference only if the prototype is similar enough, and too low a threshold makes reconstruction pass through many levels (Manning, Raghavan, and Schütze, 2008, §20.4). A threshold alone does not stop this example. Row $i$ shares $i - 1$ of its $i$ entries with the row before it, a Jaccard coefficient of $(i-1)/i$, which approaches 1, so any threshold below 1 accepts every prototype from some row on. Bounding the depth requires an explicit limit on the length of reference chains: the encoder writes a row in full whenever coding it by reference would exceed the limit. The WebGraph framework has such a parameter, the maximum reference count (Boldi and Vigna, 2004, §4). With a limit of $L$, decoding any row follows at most $L$ references, at the cost of one full row in every $L + 1$ in this example.

Problem 6 (gap-encoding a list). Page 5000 links to pages 4998, 5001, 5002, 5003, 5040, 5300, 9000 and 70000. How many bytes does the list take as 32-bit identifiers, and how many as variable-byte gaps?

As 32-bit identifiers the eight entries take $8 \times 4 = 32$ bytes. The gaps are the first identifier and then the differences:

$$4998,\ 3,\ 1,\ 1,\ 37,\ 260,\ 3700,\ 61000.$$

A variable-byte code holds 7 bits of the number in each byte, so one byte covers values up to 127, two bytes up to 16,383, and three bytes up to 2,097,151. The values 3, 1, 1 and 37 take one byte each. The values 4998, 260 and 3700 take two. The value 61000 takes three. The total is $4 \times 1 + 3 \times 2 + 3 = 13$ bytes, about 41 percent of the original. The five links to the page's own neighborhood cost 6 bytes in all, and the three distant ones cost 7.

What we have learned

A large crawl is divided by host. Modular hashing moves four fifths of the hosts when a fifth node joins, while consistent hashing moves only the new node's share, and virtual nodes even out the load. Content fingerprints are partitioned by fingerprint, since copies cross hosts. The link graph fits in memory because locality makes gaps small: one page's 28 bytes of links became 9, and a similar page's list was stored by reference in 4.

The stored graph says which pages link where. PageRank computes from this graph a score of which pages matter most.

References

  • Bharat, K., Broder, A., Henzinger, M., Kumar, P., and Venkatasubramanian, S. (1998). The connectivity server: Fast access to linkage information on the web. Computer Networks and ISDN Systems, 30(1–7), 469–477. record
  • Boldi, P., Codenotti, B., Santini, M., and Vigna, S. (2004). UbiCrawler: A scalable fully distributed web crawler. Software: Practice and Experience, 34(8), 711–726. record
  • Boldi, P., and Vigna, S. (2004). The WebGraph framework I: Compression techniques. In Proceedings of WWW 2004, 595–602. record
  • Croft, W. B., Metzler, D., and Strohman, T. (2010). Search Engines: Information Retrieval in Practice, section 3.2.7. Addison-Wesley. record · 12 pages
  • Karger, D., Lehman, E., Leighton, T., Levine, M., Lewin, D., and Panigrahy, R. (1997). Consistent hashing and random trees: Distributed caching protocols for relieving hot spots on the World Wide Web. In Proceedings of the 29th ACM Symposium on Theory of Computing (STOC 1997), 654–663. record
  • Manning, C. D., Raghavan, P., and Schütze, H. (2008). Introduction to Information Retrieval, sections 20.2 and 20.4. Cambridge University Press. record · 102 pages
  • Randall, K. H., Stata, R., Wickremesinghe, R. G., and Wiener, J. L. (2002). The Link Database: Fast access to graphs of the web. In Proceedings of the Data Compression Conference (DCC 2002), 122–131. record

Reviewed: verified, 16 Nov 2026 · citations checked, 16 Nov 2026 · editorial review, 23 Nov 2026 · 10 revisions