skip to content

Adding a replica of a large graph-indexed vector shard: do you rebuild the index on the new node or ship the built index files?

level: seniorimportance: should knowfreq 30%

answer

  1. CPU hours versus network minutes
  2. same graph or a sibling graph
  3. a consistent copy point
  4. replay writes since the copy

basics

~20 s

Shipping the built files is usually faster and gives an identical replica, but needs a consistent copy, a compatible index format and a replay of writes since the copy. Rebuilding often costs hours of CPU and yields a slightly different graph.

solid answer

~50 s

A replica must end up with the shard's vectors and a working index over them. **Rebuilding** re-inserts every vector into a fresh graph on the new node: it needs no compatibility between nodes, but graph construction is CPU-heavy (often hours for tens of millions of vectors) and, because insertion order and random layer choice shape the graph, the new replica answers some queries slightly differently from the old one. **Shipping** copies the built index files: transfer is network-bound and usually takes minutes, and the copy is identical, so replicas agree. It needs a consistent point-in-time copy while the source keeps taking writes, a replay of the writes made since that point, and the same index format on both sides. Ship by default; rebuild when formats differ during an upgrade, when you want different build parameters, or when the source files are suspect.

go deeper

for a junior

Recall the two options: build a new graph on the new node from the vectors, or copy the finished index files across.

for a middle

Explain why a rebuild is CPU-bound and non-deterministic, and why shipping needs a point-in-time copy plus a replay of later writes.

for a senior

Size both with numbers, choose shipping by default, and name the cases that force a rebuild. Verify the new replica before it takes traffic.

for a principal

Set the team's default seeding path and its verification gate, and decide whether replicas must agree byte for byte, which rules rebuilt replicas out.

## What a new replica has to hold A **replica** of a shard is a complete, independent copy: the shard's vectors and the **approximate nearest-neighbour index** built over them, here a graph index such as HNSW. Before it takes traffic it must hold the same vectors as the existing copies, an index that finds them, and every write made up to the moment it joins. There are two ways to get there. ## Option 1: rebuild the index on the new node The new node receives the raw vectors (from the source replica, or from wherever the team keeps vectors outside the store) and inserts every one into a fresh graph. - **Cost is CPU.** Graph insertion is the expensive part of a graph index: each insert runs a search to find neighbours and then rewires links. For a scenario's 30 million vectors at a scenario's 3,000 inserts per second on one node, the build takes 30,000,000 / 3,000 = **10,000 seconds, about 2.8 hours**, before catch-up. - **The result is a sibling, not a twin.** Graph construction depends on insertion order, on the random layer each vector is assigned and, with parallel inserts, on thread timing. Two builds over the same vectors produce different graphs with similar recall. Near the cut-off, the same query can return a different top-k depending on which replica answered. - **It needs no compatibility.** The new node can run a newer version, a different index format or different build parameters. ## Option 2: ship the built index files The new node receives the source replica's index files as they are. - **Cost is network and disk.** The same scenario's shard is about 123 GB of vectors (30,000,000 x 1,024 dimensions x 4 bytes = 122.88 GB) plus about 4 GB of graph links. At an effective 5 Gbit/s, roughly 0.625 GB/s, 127 GB transfers in about **200 seconds**, a little over three minutes. - **The result is a twin.** Byte-identical files return identical results, so replicas agree on every query. - **It needs a consistent copy point.** The source keeps taking writes while its files are copied. The copy must be a point-in-time view, which segment-based or copy-on-write files make easy and a graph updated in place makes hard. - **It needs catch-up.** Writes made after the copy point are replayed from the store's write log before the replica serves. How long acknowledged writes take to appear on every replica is a separate visibility question; here it only gates when the new replica joins. - **It needs compatibility.** The same index format and version on both nodes. The copy also inherits the source's build parameters, so shipping cannot change them. ## Side by side | | Rebuild on the new node | Ship built files | |---|---|---| | Dominant cost | CPU, often hours | Network and disk, often minutes | | Load on the source replica | Low if vectors come from elsewhere | Disk and network read while serving | | Result | Similar recall, slightly different graph | Identical index, identical results | | Needs a consistent copy point | No | Yes | | Needs catch-up from the write log | Yes, for writes during the build | Yes, for writes since the copy point | | Works across index format versions | Yes | No | ## A practical procedure 1. Prefer shipping. Take a point-in-time copy of the shard's index files and note its position in the write log. 2. Throttle the transfer so the source replica keeps serving within its latency budget. 3. Load the files on the new node and replay the write log from the noted position until the replica is current. 4. Verify before routing traffic: vector count, file checksums, and a sample of queries whose results must match the source replica exactly. 5. Add the replica to routing. Only then does it share the read load. Fall back to a rebuild when a rolling upgrade has changed the index format between versions, when the team wants different build parameters on the new copies, or when the source files are suspected of corruption and copying them would spread it. ## Why identical replicas matter Rebuilt replicas are not wrong, but they disagree at the margin. Users refreshing a page can see results reorder as the load balancer switches replicas; result caches and comparison tests disagree with themselves; and debugging a bad answer needs knowing which replica served it. Shipping files removes that whole class of confusion.

  • Why does it matter that a rebuilt replica's graph differs from the existing replica's?
    Because replicas then answer the same query with slightly different top-k near the cut-off. Results reorder between refreshes as traffic moves across replicas, caches and comparison tests disagree, and investigating a bad result needs knowing which copy served it. Shipped, byte-identical files avoid that.
  • When is rebuilding the right choice despite the CPU cost?
    When the index format or version differs between nodes, as during a rolling upgrade; when the team wants different build parameters on the new copies; when the source files are suspected of corruption; or when the store cannot produce a consistent point-in-time copy while it serves writes.

  • A replica needs only the raw vectors; the index can be fetched on demand.
  • Rebuilding a graph index from the same vectors gives an identical graph.
  • Copying index files while writes continue gives a usable replica without catch-up.
  • Built index files can be shipped between any two versions of a store.
  • A rebuild's cost is mostly network transfer, not CPU.