Edge RAG latency: when moving retrieval to the edge is faster
Edge RAG latency depends on the connection more than on the edge. I measured five deployment topologies for the retrieval step of RAG (query embedding plus vector search) with 30,000 requests from five regions. On reused connections, a pooled edge Worker was 16 ms faster than a central server near the database, and 52 to 133 ms slower for distant users. On new connections, the pooled Worker beat the central server everywhere outside the database's region, by 151 to 298 ms, because TLS ends at the edge.
By Mohammad Safari · Last updated
What edge RAG latency is made of
Edge RAG latency is the time from a user's request to the retrieved context being ready, when part of that work runs at a CDN point of presence (PoP) near the user instead of in one cloud region. It is the sum of four terms, and moving work to the edge changes each one differently:
- Connection setup: TCP and TLS on a new connection. The edge always shortens it, because TLS ends at a nearby PoP.
- Query embedding: faster or slower at the edge, depending on how fast the PoP serves the embedding model.
- The path to the vector database: long when the data stays central; pooling makes it tolerable, and only a copy near the user makes it short.
- Vector search itself: 4 ms here, the same wherever it runs.
Generation, and so time to first token, is outside this study: it measures the retrieval prefix that has to finish before generation can start.
The five topologies tested
- Centralized: one server in Virginia (AWS us-east-1) embeds the query on CPU and searches pgvector over a pooled in-region connection.
- Central + edge TLS: the same server behind a Cloudflare edge proxy, so TLS ends near the user while all computation stays central.
- Edge, unpooled: a Cloudflare Worker embeds the query with Workers AI and opens a new database connection per request.
- Edge, pooled: the same Worker reaching the central database through Cloudflare Hyperdrive's connection pool.
- Edge, Sydney DB: the pooled Worker pointed at a copy of the database in Sydney. It is a near-user copy only for the Sydney probe; from the other regions it is a distant database.
Test setup
- Data: 100,000 MS MARCO passages, 768-dimensional bge-base-en-v1.5 embeddings, PostgreSQL 17.11 with pgvector 0.8.6, HNSW with
ef_search = 100, top 5 results. - Servers and probes: AWS m7i-flex.large instances (2 vCPU, 8 GB) in Virginia, London, São Paulo, Mumbai and Sydney; Cloudflare Workers, Workers AI and Hyperdrive on the free plan.
- Requests: per topology and mode, each probe sent 10 untimed warm-up requests and 300 timed ones at 0.5 s spacing, in two passes: 600 per cell, 30,000 in total, all HTTP 200 with server timing. Warm reuses one keep-alive connection; cold opens a new TCP and TLS connection per request.
- When: one session on 1 October 2026, 01:20 to 03:38 UTC. Results are medians with bootstrap 95% confidence intervals in the paper.
Measured: warm connections
On reused connections, the central server stays fastest for distant users unless the data is near them too. The fastest topology per region is in bold.
| Probe | Centralized | Central + edge TLS | Edge, unpooled | Edge, pooled | Edge, Sydney DB |
|---|---|---|---|---|---|
| Virginia (DB region) | 92 | 114 | 141 | 76 | 316 |
| London | 167 | 187 | 923 | 150 | 397 |
| São Paulo | 205 | 236 | 1,360 | 257 | 495 |
| Mumbai | 275 | 303 | 2,595 | 353 | 411 |
| Sydney | 295 | 324 | 2,358 | 427 | 191 |
Measured: new connections
A new connection to a distant central server costs two extra long round trips for TCP and TLS 1.3. The edge topologies end TLS at the PoP in 6 to 15 ms, so on new connections both the pooled Worker and the edge TLS proxy beat the central server in every region outside Virginia.
| Probe | Centralized | Central + edge TLS | Edge, unpooled | Edge, pooled | Edge, Sydney DB |
|---|---|---|---|---|---|
| Virginia (DB region) | 96 | 134 | 166 | 106 | 348 |
| London | 327 | 205 | 941 | 170 | 417 |
| São Paulo | 436 | 251 | 1,431 | 285 | 508 |
| Mumbai | 655 | 319 | 2,654 | 373 | 351 |
| Sydney | 738 | 338 | 2,363 | 441 | 205 |
Where the time goes
The server-reported stage times explain the tables. R is the measured round-trip time from each probe to the central server.
| Probe | R (ms) | Embed, central CPU | Embed, edge | Search, central | Search, pooled | Search, unpooled |
|---|---|---|---|---|---|---|
| Virginia | 1.1 | 85 | 47 | 4 | 14 | 71 |
| London | 76.9 | 84 | 39 | 4 | 98 | 870 |
| São Paulo | 115.1 | 85 | 91 | 4 | 152 | 1,239 |
| Mumbai | 184.9 | 84 | 53 | 4 | 294 | 2,538 |
| Sydney | 218.1 | 83 | 165 | 4 | 254 | 2,174 |
Why a pooled edge Worker loses far from the database
Two measured effects. First, the pooled query path costs more than one round trip: 1.15 to 1.57 round trips (median 1.25), and the minimum search time in every region exceeded one round trip, so nothing was served from a cache. Second, edge embedding time depends on the PoP: a median of 39 to 53 ms at London, Virginia and Mumbai, below the central server's 84 ms, but 91 ms at São Paulo and 165 ms at Sydney.
The tails differ even more. The 99th-percentile edge embedding time was 83 ms at London and 385 ms at Sydney, with maxima of 2 to 28 seconds; the central CPU embedder's 99th percentile was 202 to 233 ms, with a maximum of 310 ms.
A database copy near the user
For the Sydney probe, the Worker with a Sydney database copy took 191 ms against 295 ms for the central server: 104 ms or 35% faster, and 236 ms faster than the pooled Worker querying Virginia. Removing a 218 ms round trip saved only about half that, because embedding at the Sydney PoP took 165 ms against 83 ms centrally. From the other four regions the same Sydney database was the slowest pooled option, 136 to 290 ms behind the central server: placing data away from the user costs more than placing it near saves.
Never connect an edge Worker to a distant database without a pool
“It takes upwards of seven round-trips (TCP handshake; TLS negotiation; then auth) to establish the connection” Cloudflare, introducing Hyperdrive
Measured with TLS and SCRAM authentication through the Workers socket API, it was 9 to 13 round trips. Unpooled search took 870 ms from London and over 2.1 seconds from Mumbai and Sydney; even next to the database it cost 71 ms against 14 ms pooled.
The statement count matters for the same reason: every statement on a wide-area path is a round trip. In pre-test requests through the London PoP, the pooled search took about 460 ms as four statements and 125 to 130 ms as one transaction.
The cheaper alternative: end TLS at the edge, keep everything central
The “central + edge TLS” topology changes nothing about where embedding and search run, yet it took Sydney from 738 to 338 ms on new connections. It was the fastest central-database option on new connections from São Paulo, Mumbai and Sydney (251, 319 and 338 ms against 285, 373 and 441 ms for the pooled Worker), and slower only at London (205 against 170 ms). The price is 20 to 31 ms on warm connections. A fair evaluation of an edge RAG architecture should include it.
The vector search is not the bottleneck at this size
Server-side search took 4 ms on 100,000 passages. On a separate benchmark with one million MS MARCO embeddings (GCP c3-standard-22, serial queries, every index in memory), HNSW beat IVFFlat at equal or higher recall:
| Index and setting | Recall@10 | p50 (ms) |
|---|---|---|
| HNSW m=16, ef_construction=64, ef_search=40 | 0.880 | 1.36 |
| HNSW m=16, ef_construction=200, ef_search=100 | 0.962 | 2.79 |
| HNSW m=32, ef_construction=200, ef_search=40 | 0.949 | 2.17 |
| HNSW m=32, ef_construction=200, ef_search=400 | 0.994 | 13.39 |
| IVFFlat lists=4000, probes=100 | 0.938 | 21.94 |
| IVFFlat lists=1000, probes=100 | 0.968 | 80.64 |
| Exact scan (200 queries) | 1.000 | 1,094.7 |
At Recall@10 of 0.994, HNSW was 82 times faster than an exact scan, and 10 to 19 times faster than the IVFFlat settings reaching 0.93 or more. HNSW index size (3,904 MB) did not change with the graph degree m.
When edge RAG is worth it
- Never deploy an edge Worker against a distant database without a connection pool.
- Mostly short sessions and new connections: terminate TLS at the edge. A TLS proxy in front of the central server matched or beat the pooled Worker from three of four distant regions.
- Long-lived warm connections from distant regions: the pooled edge Worker is the worse choice.
- A regional copy of the vector database pays off only near the users it serves, and only after checking the embedding latency at the PoPs that will serve it: slow edge inference cost half the gain in Sydney.
For regions not probed, an additive latency model in the repository predicts the centralized and near-copy topologies within 4%. Using one round trip per pooled query and seven per new connection, it underestimates the edge topologies by 7 to 42%; the calibrated values are 1.25 and 10.
Limitations
- One session of about two hours and twenty minutes; a second session was lost before collection, so time-of-day variation is not captured.
- Five concurrent probes shared one two-core central server, adding roughly 15 ms to its embedding time; the Virginia probe ran on that server.
- Probes are data-centre machines; residential and mobile last-mile latency would add to every topology and favour TLS termination at the edge.
- One provider pair (Cloudflare free plan, AWS), one embedding model, ten distinct queries, 100,000 passages. A GPU-backed central embedder would favour the central server on warm connections.
- The Sydney copy is an independently loaded database, not a streaming replica; replication lag is not measured.
- The paper was revised on 30 September 2026 after an audit against its sources and raw data; the removed claims are listed in SOURCES.md.
Related work: the EdgeRAG paper (arXiv 2412.21023) studies retrieval on a memory-limited edge device; this study measures network topology instead. For admission control once generation starts, see KV-cache-aware admission in TokenFlow; to skip retrieval and generation for repeated questions, see the Semantic Cache Policy Engine.
Reproduce
The repository holds the Worker, the baseline server, the probes and all 30,000 rows of raw data:
git clone https://github.com/mosafariuk/edge-rag-topologies && cd edge-rag-topologies python3 probe/analyze.py probe/results/*.csv # Tables I–II: medians, CIs, stage times python3 latency_sim.py --compare probe/results/summary.json # Table III: model vs measurement python3 latency_sim.py --rtt sydney=205 # model a region with your own measured RTT
Sources
- Paper (IEEE format, 9 pages): ieee_manuscript.pdf; preprint DOI 10.5281/zenodo.24447712
- Code and raw data: github.com/mosafariuk/edge-rag-topologies (end-to-end dataset in probe/results). Paper and data CC BY 4.0, code MIT.
- Also published on LinkedIn (22 November 2026): Does moving RAG to the edge make it faster? I measured it