D1 read replication: what the Sessions API actually guarantees
Cloudflare D1 can serve reads from replicas worldwide, but only for code that uses sessions. Here's what they guarantee and what they cost.

On this page
Cloudflare D1 can keep read-only copies of a database close to your users, which lowers read latency and raises read throughput. There's a catch that's easy to miss: replicas only serve queries that go through the Sessions API. Without it, "all queries will continue to be executed only by the primary database"[1]Global read replication. Writes always go to the primary, and replicas are updated asynchronously, so a replica can lag behind it[1]Global read replication.
Cloudflare announced read replication as a public beta on 10 April 2025[2]Sequential consistency without borders: how D1 implements global read replication. The current documentation, last updated 10 August 2026, describes the feature without labelling it beta or generally available, so check its status before you depend on it for production traffic[1]Global read replication.
Why replicas need sessions
The problem sessions solve is routing. Cloudflare's write-up states plainly that "there's no way to ensure that requests from the same client get routed to the same replica for every request"[2]Sequential consistency without borders: how D1 implements global read replication. Because replicas lag by different amounts, a client could write a row on one request and fail to see it on the next, or watch data appear to go backwards in time.
A session fixes that with bookmarks. Every write to the primary produces a bookmark, a Lamport timestamp that is greater than any earlier bookmark for that database. A session remembers the newest bookmark it has seen, and a replica asked to serve that session must catch up to it before answering[2]Sequential consistency without borders: how D1 implements global read replication. The result is sequential consistency for every query in the session: monotonic reads, monotonic writes, writes that follow reads, and reading your own writes[1]Global read replication.
// Carry the bookmark between requests so each one starts at least as fresh as the last.
const bookmark = request.headers.get("x-d1-bookmark") ?? "first-unconstrained";
const session = env.DB.withSession(bookmark);
const { results } = await session.prepare("SELECT * FROM posts WHERE status = ?").bind("published").all();
const response = Response.json(results);
response.headers.set("x-d1-bookmark", session.getBookmark() ?? "");
return response;
Choosing where a session starts
withSession() takes one of three starting points[1]Global read replication:
- No argument, or
"first-unconstrained": the first query can run on the primary or any replica. This is the fastest option and fine for pages that don't need the very latest write. "first-primary": the first query goes to the primary, for when the data must be current, such as right after a user saves something.- A bookmark: the session starts at least as up to date as the session that produced it. This is how the example above keeps one client's requests consistent with each other.
Where replicas run and what they cost
D1 creates a replica in every supported region, including the primary's own: ENAM, WNAM, WEUR, EEUR, APAC and OC. Cloudflare notes those locations may change[1]Global read replication. Replicas add no storage or compute charges; billing stays based on rows_read and rows_written whether replication is on or off[1]Global read replication.
To see where a query ran, check served_by_region and served_by_primary in the result's meta object. Both are undefined under wrangler dev, so test routing against a deployed Worker[1]Global read replication.
Where it fits, and where it doesn't
The limits are worth knowing before you turn it on[1]Global read replication:
- Replication only helps reads. A write-heavy workload still funnels through one primary.
- The Sessions API is available through the Worker binding only, not the REST API.
- Turning replication off can take up to 24 hours to stop replicas serving requests. Code that uses sessions keeps working either way, so you can adopt the API before enabling replicas.
Our take: read-mostly workloads, such as a blog, documentation or a product catalogue, are the obvious fit, because almost every request is a read and a few seconds of replica lag rarely matters. The design choice that matters most is where you start each session. Use first-primary straight after writes that the user expects to see, and pass bookmarks between requests everywhere else.
Sources
- 1Global read replicationCommunityCloudflare Docs · 2026-08-10
- 2Sequential consistency without borders: how D1 implements global read replicationCommunityThe Cloudflare Blog · 2025-04-10
“there's no way to ensure that requests from the same client get routed to the same replica for every request”