Direct answer: Every safety filter added to a retrieval-augmented pipeline sits in the request path, so each one adds latency, and the slowest requests feel the pile-up first. The fixes are standard systems work: cache results, run cheap checks before expensive ones, and refuse safely when a check times out.

Retrieval-augmented generation (RAG) answers questions from your documents: embed the query, search a vector index, feed the retrieved passages to the model, return the answer. Adding safety checks to that pipeline looks free on a diagram and is never free in production, because every check is another call standing between the user and the answer.

The trending query I Made My RAG Safer. It Got Worse Under Load circulated on dev.to trending in late November 2026, and the story underneath is a durable one about capacity. An improvement that holds at ten requests per minute and collapses at a hundred has a scheduling problem, and the same shape recurs in any system that keeps adding checks to a path.

Where the milliseconds go

The base path already makes several calls: one to embed the query, one to search the vector index, one to the language model. Safety filters check both the incoming query and the retrieved text, so a guarded pipeline adds at least two more calls, and they run in sequence with everything else.

Serial stages add up arithmetically, and position matters. A filter that sits before the expensive generation step delays everything queued behind it, so its cost lands on every request, on every answer, all day.

QueryembedQuery checkadded stageVector searchretrieveText checkadded stageThen the model, last in line. Each check is a serial stage.

Why the tail feels it first

Latency under load is judged at the tail: the slowest 1% of requests. The tail is where cache misses, retries, and queueing land, so an uncached request that runs every filter feels the load long before the median request does.

Caching changes the ratio between the two populations. Frequent queries get stored answers and skip every stage, while rare queries pay for the full guarded path, so the heavier the load, the wider the gap grows.

missedyour Brain mapquiz yourselfmasteredWatch your weak spots turn green.

Drop in your PDF - it doesn't leave your device.
Every miss becomes a red node on your map.
Free plan: 21 nodes, no card, no countdown.

Open Brain - free
NaN

The mitigations are ordinary capacity engineering applied to a model pipeline. Cheap checks run first, so a malformed query is rejected before it reaches the vector index, and timeouts get a designed fallback: when a check stalls, the system degrades to a safe refusal, which answers nothing yet stays correct.

  1. Cache frequent query results so common questions skip every stage.
  2. Order checks cheapest first to reject bad requests early.
  3. Set per-stage timeouts with a safe refusal as the fallback.
  4. Load-test the guarded path at the tail before the change ships.

The ordered list is short because the levers are few: remove calls, reorder calls, or bound calls. Anything else in the latency path is a new demand on capacity wearing a policy badge.

Budget safety and capacity together

A check is a demand on capacity like any other call, so a safety roadmap is a capacity roadmap. Two filters that pass review on a quiet Tuesday can dominate the tail on a busy Friday, and the review that missed it compared latency on an empty path.

The lesson is that adding checks to a path is adding work to a path: budget the latency, budget the load, and ship them in the same change.

Key takeaways

  • RAG answers from documents by embedding the query, searching a vector index, and feeding results to the model.
  • Safety filters that inspect the query and the retrieved text add serial stages to that path.
  • Tail latency, the slowest 1% of requests, grows fastest under load because uncached paths pay for every stage.
  • Cache frequent queries, run cheap checks before expensive ones, and degrade to a safe refusal on timeout.
  • Adding checks means adding capacity demand, so latency and load get budgeted together.

Quick answers

What is RAG?
Retrieval-augmented generation: the system retrieves passages from your documents and the model answers from them.

Why did latency rise after adding filters?
Each filter is another serial call between the user and the answer, and the costs add up arithmetically.

Which requests slow down first?
The uncached tail, the slowest 1%, which pays for every stage including retries and queueing.

What is a safe refusal?
A designed fallback that returns a clear non-answer when a safety check times out under load.

What is the first mitigation to try?
Cache frequent query results, so common questions skip the guarded path entirely.

One thing to do tonight

Trace one request through your own retrieval pipeline tonight and count the serial calls, filters included. That number, set against your latency target, tells you whether the next check fits.