A retrieval-augmented pipeline's total latency is the sum of five to seven discrete stages — query rewrite, embedding, retrieval, reranking, context assembly, and generation — each adding tens to hundreds of milliseconds. Users don't experience an average; they experience the worst stage that isn't hidden by streaming. Budgeting means allocating a millisecond ceiling per stage from your end-to-end SLA, then cutting or masking whichever stage blows it.
Quick Answer: Take your user-facing latency SLA, subtract generation time (the biggest and least compressible chunk), and split what's left across rewrite, retrieval, and rerank based on which ones run in parallel versus serially. Cache aggressively, parallelize retrieval across shards or indexes, and stream tokens the instant the first ones are ready.
Why "Fast Enough" Requires a Stage-by-Stage Budget, Not a Single Target
A single end-to-end latency target tells engineers nothing about where to spend their optimization effort, so teams default to shaving the easiest stage instead of the slowest one. Decomposing the budget into per-stage ceilings turns one vague goal into several concrete, testable ones — each owned by whoever built that stage.
Jakob Nielsen's usability research (Nielsen Norman Group) established three response-time thresholds that still hold for chat-style interfaces: 0.1 seconds feels instantaneous, 1 second keeps a user's flow of thought uninterrupted, and 10 seconds is the outer limit before attention drifts elsewhere. A RAG system replying to a support query should treat "first visible token" as the 1-second boundary, not the final answer — that distinction is the whole basis for the streaming section below.
Most teams write an SLA like "answers in under 3 seconds" and stop there. That number needs to be broken into a waterfall: how many milliseconds each stage is allowed to consume, given that some run serially and others can run in parallel.
The Five-to-Seven Stage Pipeline, Named
Before budgeting anything, name the stages you're actually running. A typical production RAG pipeline looks like this:
- Query rewrite/expansion — reformulating the user's raw query, sometimes with an LLM call, to improve retrieval recall.
- Embedding — converting the (rewritten) query into a vector.
- Retrieval — the nearest-neighbor or hybrid (
BM25+ vector) search against your index. - Reranking — a cross-encoder or
LLM-as-judge pass reordering the top-k candidates by relevance. - Context assembly — deduplication, truncation, and prompt templating with the retrieved chunks.
- Generation — the actual
LLMcall producing the answer. - Post-processing — citation formatting, guardrail checks, or a second-opinion pass, if you run one.
Chunking strategy decisions made upstream directly affect how much stage 3 and stage 5 cost — see chunking strategy and retrieval quality for how chunk size trades off against the number of round trips retrieval needs.
Building the Waterfall: Where Milliseconds Actually Hide
A latency waterfall is a stacked bar showing cumulative time consumed at each pipeline stage, revealing which stages run serially (additive) and which run in parallel (only the slowest counts). Most teams discover the biggest offenders aren't the stages they assumed — reranking and context assembly routinely hide more latency than retrieval itself.
Here's a representative waterfall for a mid-sized RAG deployment (single-region, ~5M document index, cross-encoder reranker):
| Stage | Typical p50 (ms) | Typical p95 (ms) | Parallelizable? | Worth cutting? |
|---|---|---|---|---|
| Query rewrite (LLM call) | 150 | 400 | No (blocks retrieval) | Yes — often skippable for short queries |
| Embedding | 15 | 40 | Yes, with retrieval batching | Rarely the bottleneck |
Retrieval (vector + BM25) | 40 | 120 | Yes, across shards | Sometimes — index tuning |
| Reranking (cross-encoder) | 180 | 500 | Partially (batch scoring) | Yes — biggest lever |
| Context assembly | 10 | 30 | No | Rarely |
| Generation (first token) | 300 | 900 | No | Streaming masks this |
| Total to first token | ~695 | ~1,990 | — | — |
The takeaway from this table: reranking and query rewrite together often cost as much as retrieval and generation combined, yet teams instrument retrieval latency religiously and leave reranking as an unmeasured black box. If you haven't put a stopwatch on your reranker specifically, that's the first gap to close.
Which Stages Are Actually Worth Cutting
Not every millisecond is equally expensive to remove. Rank stages by removal cost versus latency payoff:
- Query rewrite — highest payoff-to-effort ratio. Route only ambiguous or short queries through a rewrite LLM call; pass clear, well-formed queries straight to retrieval.
- Reranking — second highest. Swap a full cross-encoder pass for a lighter distillation model, or rerank only the top 20 candidates instead of top 100.
- Retrieval — usually already fast; gains here come from index structure (
HNSWparameters, shard count), not algorithm changes. - Generation — the least compressible stage per token, but streaming (below) removes it from the perceived budget almost entirely.
- Context assembly — rarely worth engineering time; it's a few array operations, not a network call.
Setting Per-Stage Targets From Your User-Facing SLA
A per-stage target should be derived backward from the user-facing promise, not forward from what each engineering team thinks is achievable. Start with the SLA for "time to first visible token," subtract your generation model's typical first-token latency, and divide the remainder across the serial pre-generation stages.
Here's the derivation, worked through with numbers:
- Set the SLA. Say your product commits to a 1.5-second time-to-first-token for 95% of queries — inside Nielsen's "uninterrupted flow" band.
- Subtract generation's floor. If your
LLMprovider's p95 first-token latency is 500ms, you have 1,000ms left for everything upstream. - Subtract fixed overhead. Context assembly and network round trips typically eat 50-100ms regardless of anything you optimize.
- Split what remains across query rewrite, retrieval, and reranking based on which run serially. If rewrite and retrieval must run in sequence but reranking can start scoring the first batch while retrieval finishes later shards, budget accordingly rather than assuming strict addition.
| Stage | Budget allocated | Rationale |
|---|---|---|
| Query rewrite | 200ms | Skip for 60%+ of queries; only pay this for the rest |
| Retrieval | 300ms | Parallel shard search, capped fan-out |
| Reranking | 350ms | Batch top-30 only, distilled model |
| Fixed overhead | 150ms | Assembly, network, guardrails |
| Total pre-generation | 1,000ms | Matches the derived budget above |
Once each team owns a number instead of a vague "make it faster," conversations change from "the pipeline feels slow" to "reranking is over budget by 120ms at p95" — a debuggable, assignable problem. This budgeting exercise sits downstream of the architectural choices covered in the four product decisions RAG forces, particularly the freshness-versus-cost tradeoff that determines how much reranking you can afford to run at all.
Caching: The Cheapest Latency You'll Ever Buy
Caching removes entire stages from the critical path for repeat or similar queries, and it's almost always the highest-ROI latency investment because it costs no accuracy trade-off when done correctly. The three layers worth building, in order of implementation effort, are query-result caching, embedding caching, and semantic caching.
- Exact-match query caching. Cache the full response for identical queries within a TTL. Cheapest to build, lowest hit rate — useful mainly for FAQ-shaped traffic.
- Embedding caching. Cache the vector for a given query string so repeated or paraphrased-but-identical queries skip the embedding stage entirely. Near-zero cost, moderate hit rate.
- Semantic caching. Cache responses keyed by embedding similarity above a threshold (e.g., cosine similarity > 0.95), so paraphrased queries ("What's your refund policy?" vs. "Can I get my money back?") hit the same cached answer. Highest payoff, but requires careful threshold tuning to avoid serving a stale or slightly-wrong cached answer for a query that only looks similar.
A word of caution from Redis Labs' published caching-pattern guidance and general distributed-systems practice: semantic caching trades a small, real correctness risk for a large latency win — always pair it with a cache-invalidation policy tied to document updates, not just a fixed TTL, or you'll silently serve outdated answers after a knowledge-base refresh.
Parallel Retrieval: Fan Out, Don't Fan Through
Retrieval across multiple indexes, shards, or data sources should run concurrently and merge results, rather than querying each source sequentially and waiting on all of them before reranking. Sequential multi-source retrieval is the single most common self-inflicted latency wound in production RAG systems, because it's the easiest way to build the pipeline first and the hardest habit to unlearn later.
Concretely: if your system retrieves from a vector index, a keyword (BM25) index, and a structured metadata filter, issue all three calls concurrently with Promise.all (or your language's equivalent) and merge/dedupe results once every call resolves — not one after another. The wall-clock cost of parallel fan-out is the slowest single source, not the sum of all sources; Google's original MapReduce-style latency arguments and every distributed-tracing vendor's documentation on fan-out patterns make the same point in different domains.
Set a hard timeout per source with graceful degradation — if the metadata filter hasn't responded in 100ms, proceed with vector and keyword results alone rather than blocking the whole pipeline on a slow source.
Streaming: Masking Latency the User Can't See Removed
Streaming tokens as they're generated changes what a user perceives as "response time" from the full generation duration to the time-to-first-token, which is typically a fraction of total latency. This is the single highest-leverage change available to a technical PM who doesn't control the retrieval or model architecture — it's a UX decision, not an infra rebuild.
The mechanism: instead of waiting for the full completion and rendering it at once, render each token (or chunk) as it arrives over a Server-Sent Events or WebSocket connection. The user starts reading before generation finishes, which converts a 2-second wait into what feels like a near-instant response followed by continuous progress — directly exploiting the perceptual gap Nielsen's thresholds describe.
Three refinements make streaming feel even faster without changing actual compute time:
- Show retrieval progress before generation starts — a "Searching your knowledge base..." indicator during the 300-500ms retrieval-plus-rerank window keeps the interface from feeling frozen.
- Stream citations incrementally as retrieved sources are confirmed relevant, rather than batching them at the end — this also gives users an early trust signal before the answer text even appears.
- Pre-warm the generation connection during retrieval so the first generation token isn't also paying a cold-start connection-setup cost.
None of this reduces the actual compute; it changes when the user perceives progress, which research on perceived-performance (including work popularized by Jakob Nielsen and separately by Google's web-vitals guidance on First Contentful Paint) has repeatedly shown matters as much to satisfaction as raw completion time.
Where Latency Erodes Trust Beyond the Final Answer
Latency doesn't only cost seconds — it costs confidence, and that erosion often starts before the user even sees a retrieval result. A pipeline that stalls silently at the reranking stage, with no visible progress, reads to the user as "broken" long before it reads as "slow."
This is a genuinely useful place to map the interaction as an emotional arc rather than a technical waterfall. Prodinja's Customer Journey emotion curve is designed to help you plot where trust rises or dips across an interaction — including the silent gaps in a RAG pipeline where a user is waiting with no feedback — so you can see whether the eroded-trust point is actually the final-answer latency, or an earlier unacknowledged pause that a progress indicator alone would fix. It's a mapping exercise, not a live latency profiler, but it's often the fastest way to spot that the real fix is a UI cue, not another millisecond shaved from reranking.
For the deeper product-decision context behind why retrieval latency and trust are linked at all, the complete guide to RAG and knowledge systems covers the architectural tradeoffs that create these latency profiles in the first place, and the customer journey complete guide covers how to map emotional highs and lows across any multi-step interaction, not just RAG.
Common Latency Mistakes That Blow the Budget
Most latency budget overruns trace back to a handful of repeatable mistakes rather than genuinely hard technical problems. Recognizing the pattern is usually faster than profiling from scratch.
| Mistake | Symptom | Fix |
|---|---|---|
| Reranking every candidate instead of top-k | Reranker latency scales with retrieval breadth | Cap reranker input to top 20-30 candidates |
| Sequential multi-source retrieval | Latency equals sum of sources, not max | Fan out with Promise.all, per-source timeout |
| No embedding/semantic cache | Every paraphrase re-pays full retrieval cost | Add a similarity-threshold semantic cache |
| Query rewrite on every query | Adds an LLM round trip even for clear queries | Route only ambiguous/short queries through rewrite |
| Batch-rendering the full answer | User perceives full generation time as the wait | Stream tokens via SSE/WebSocket |
| No per-stage instrumentation | Nobody knows which stage is actually over budget | Trace each stage independently, not just end-to-end |
Access-control checks are another latency source teams often forget to budget for — a permission filter applied at query time on every retrieved chunk can add real overhead if it's not indexed alongside the content itself. The access control and permissions guide for RAG covers how to structure that filtering so it doesn't become an unbudgeted seventh stage.
Key Takeaways
- Decompose one SLA into per-stage budgets derived backward from time-to-first-token, not forward from what each team assumes is achievable.
- Reranking and query rewrite are frequently the hidden cost centers, not retrieval — instrument them individually before assuming retrieval is the bottleneck.
- A latency waterfall table — showing p50/p95 per stage and whether it's parallelizable — turns vague "it feels slow" complaints into an assignable, debuggable problem.
- Caching (exact-match, embedding, and semantic) is the highest-ROI latency investment available, provided it's paired with an invalidation policy tied to content updates.
- Parallel fan-out across retrieval sources costs only as much as the slowest source, not the sum — sequential multi-source retrieval is a common, easily fixed mistake.
- Streaming changes perceived latency more than any backend optimization, converting a multi-second wait into a near-instant first token followed by visible progress.
- Trust erodes at silent, unacknowledged waits, not just at the final answer — mapping the full interaction, not just the response-time number, often reveals the real fix.
Frequently Asked Questions
What is an acceptable latency for a RAG pipeline?
Most production RAG systems target under 1-2 seconds to first visible token for a 95th-percentile query, aligning with Jakob Nielsen's research showing 1 second as the threshold for uninterrupted user flow. Total completion time can run longer if streaming keeps the user actively reading.
Which RAG pipeline stage usually causes the most latency?
Reranking and query rewrite are the most commonly underestimated stages, often together costing as much as retrieval and generation combined, because teams instrument retrieval and generation but leave reranking latency unmeasured. Profile every stage individually before assuming retrieval is the bottleneck.
Does caching hurt answer accuracy in a RAG system?
Exact-match and embedding caching carry essentially no accuracy risk since they cache identical inputs. Semantic caching (keyed by similarity threshold) carries a small, real risk of serving a stale or near-miss answer, which is why it needs an invalidation policy tied to document updates rather than a fixed TTL alone.
How much does streaming actually reduce latency?
Streaming doesn't reduce total compute time at all — it changes what the user perceives as "waiting" from full generation time down to time-to-first-token, which is often 20-40% of total completion time. It's a perceived-performance fix, not a backend speed fix.
Should I parallelize retrieval across multiple data sources?
Yes — fanning out concurrent calls to every retrieval source (vector index, keyword index, metadata filter) and merging results once all resolve keeps total retrieval latency equal to the slowest single source rather than the sum of all sources. Set a per-source timeout so one slow source doesn't block the entire pipeline.