4 People often want to know how Xapian will scale. The short answer is
5 "very well" - an early version of the software powered the (now defunct)
6 Webtop search engine, which offered a search over around 500 million web
7 pages (around 1.5 terabytes of database files). Searches took less than
10 In terms of current deployments, `gmane <http://search.gmane.org/>`_
11 indexes and searches nearly 100 million mail messages on a single server
12 at the time of writing (2012), and we've had user reports of systems with
13 more than 250 million documents.
18 One effect to be aware of when designing benchmarks is that queries will
19 be a lot slower when nothing is cached. So the first few queries on a
20 database which hasn't been searched recently will be unrepresentatively
21 slow compared to the typical case.
23 In real use, pretty much all the non-leaf blocks from the B-trees being
24 used for the search will be cached pretty quickly, as well as many
25 commonly used leaf blocks.
27 General Scalability Considerations
28 ----------------------------------
30 In a large search application, I/O will end up being the limiting
31 factor. So you want a RAID setup optimised for fast reading, lots of RAM
32 in the box so the OS can cache lots of disk blocks (the access patterns
33 typically mean that you only need to cache a few percent of the database
34 to eliminate most disk cache misses).
36 It also means that reducing the database size is usually a win. Xapian's
37 disk-based databases compress the information in the tables in ways which
38 work well given the nature of the data but aren't too expensive to
39 unpack (e.g. lists of sorted docids are stored as differences with
40 smaller values encoded in fewer bytes). There is further potential for
41 improving the encodings used.
43 Another way to reduce disk I/O is to run databases through
44 xapian-compact. The Btree manager usually leaves some spare space in
45 each block so that updates are more efficient (though there are
46 heuristics which will fill blocks fuller when they detect a long
47 sequence of sequential insertions, which means adding documents to the
48 end of an empty database will produce fairly compact tables, apart from
49 the postlist table). Compacting makes all blocks as full as possible,
50 and so reduces the size of the database. It also produces a database
51 with revision 1 which is inherently faster to search. The penalty is
52 that updates will be slow for a while, as they'll result in a lot of
53 block splitting when all blocks are full.
55 Splitting the data over several databases is generally a good strategy.
56 Once each has finished being updated, compact it to make it small and
59 A multiple-database scheme works particularly well if you want a rolling
60 web index where the contents of the oldest database can be rechecked and
61 live links put back into a new database which, once built, replaces the
62 oldest database. It's also good for a news-type application where older
63 documents should expire from the index.
68 The glass backend (which is currently the default and recommended
69 backend) stores the indexes in several files containing Btree tables. If
70 you're indexing with positional information (for phrase searching) the
71 term positions table is usually the largest.
73 The current limits are:
75 - Xapian uses unsigned 32-bit integers for document ids by default, which
76 means a limit of just over 4 billion documents in a database. Xapian 1.4
77 can be built to use 64-bit document ids and term counts, and the glass
78 backend will then handle 64-bit document ids (and the databases are
79 compatible with a standard build provided you don't actually use docids >=
81 - If you search many databases concurrently, you may hit the
82 per-process file-descriptor limit - each glass database uses between
83 1 and 6 fds depending which tables are present. Some Unix-like OSes
84 allow this limit to be raised. Another way to avoid it (and to spread
85 the search load) is to use the remote backend to search databases on
86 a cluster of machines.
87 - If the OS has a filesize limit, that obviously applies to Xapian (a
88 2GB limit used to be common for older operating systems). The
89 xapian-core configure script will attempt to detect and automatically
90 enable support for "LARGE FILES" where possible.
92 So what is the limit for a modern OS? Taking Linux 2.6 as an example,
93 ext4 allows files up to 16TB and filesystems up to 1EB, while btrfs
94 allows files and filesystems up to 16EB (`figures from
95 Wikipedia <https://en.wikipedia.org/wiki/Comparison_of_file_systems>`_).
96 - The B-trees use a 32-bit unsigned block count. The default blocksize
97 is 8K which limits you to 32TB tables. You can increase the blocksize
98 if this is a problem, but it's best to do it before you create the
99 database as otherwise you need to use xapian-compact to make a
100 compacted copy of the database with the new blocksize, and that will
101 take a while for such a large database. The maximum blocksize
102 currently allowed is 64K, which limits you to 256TB tables.
103 - Xapian stores the total length (i.e. number of terms) of all the
104 documents in a database so it can calculate the average document
105 length. This is currently handled as an unsigned 64-bit quantity so
106 it's not likely to be a limit you'll hit. It's listed here for
109 If you've further questions about scalability, ask on the mailing lists
110 - people using Xapian to search large databases may be able to make