Healthy p50 with a tripled p99 is the signature of resource contention: most queries miss the rebuild, but the unlucky few collide with build threads or cache eviction and stall hard.
Imagine a kitchen where the staff usually plates orders quickly because each cook has a clear counter. Now the manager starts a deep clean of one section in the background, taking over an oven and one of the prep stations. Most orders flow through the unused stations just fine and arrive on time. But a few orders need the section being cleaned. Those orders wait for the deep clean to pause, or get bumped from station to station while space frees up, so they take much longer than usual. The median order looks healthy. The slowest few are terrible. That is what tail latency measures, and that is what an index rebuild does to queries.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
The latency-shape mismatch (median fine, tail terrible) is one of the most diagnostic signals in distributed systems. It points at contention rather than at algorithmic change, and it shows up wherever a background workload shares finite resources with a foreground workload.
Vector index rebuilds are a particularly clean example because the rebuild is bandwidth-heavy, cache-hostile, and CPU-bound all at once. This section walks through why the latency distribution behaves that way, how vector engines specifically suffer the contention, and what operational patterns make the rebuild invisible to live traffic.
Why latency is right-skewed at steady state
A query against a vector index does the same algorithmic work every time, but the wall-clock time varies dramatically. The variance comes from the system around the algorithm.
Cache state. A query that hits a hot page in memory finishes in microseconds. A query that misses and reads from disk finishes in milliseconds. The ratio is roughly 1000x.
Scheduler luck. A query that runs on a core with no contention finishes uninterrupted. A query that gets preempted mid-flight by another process waits its quantum out.
NUMA effects. On a multi-socket box, accessing memory across sockets is 1.5 to 3x slower than local access. The query that lands on the wrong core has higher per-access cost.
Garbage collection or memory allocator pauses. Brief stalls of single-digit milliseconds for application-level work hit some queries and not others.
At steady state, these slow paths are rare, so p50 sits near the algorithmic floor. The right tail is where the slow paths accumulate; p99 might be 5 to 20x p50 in a healthy production system.
When you add a background workload, the slow paths get slower. The cache misses get longer because the rebuild evicted more pages. The scheduler preemptions get worse because more threads are competing. The tail grows proportionally to the worst-case stall the new contention adds, while the median barely moves.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- Qdrant supports aliases so a rebuilt collection on a sidecar node can be promoted atomically, avoiding in-place rebuild on the serving node
- pgvector HNSW build is single-threaded by default and saturates one CPU and the page cache; teams run it on a maintenance replica before promoting
What an interviewer would ask next. Try answering before peeking at the approach.
QHow would you architect rebuilds so live serving nodes never see the load?
Build on a separate replica or a fresh node, then promote via alias or read-path switch. Qdrant aliases, Pinecone namespaces, and Elasticsearch index aliases all support this. The promotion is atomic and the live nodes never burned CPU on the build.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Assuming p50 and p99 move together, then dismissing the rebuild tail spike as noise instead of treating it as the contention signal it actually is.
60 second bullets to scan on the way to the call.
Why latency distributions are right-skewed even at steady state
Which resources an HNSW rebuild competes for (CPU, memory bandwidth, page cache, disk I/O)
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.