Edge Databases for Low-Latency Apps: D1, Turso, Neon Serverless
Edge compute is useless without an edge data layer. Three serverless databases that put data within ms of your edge functions, with the tradeoffs that aren't on the marketing pages.
Key takeaways
- Edge databases cut read latency by serving reads near users while writes still go to one primary.
- Use Cloudflare D1 for read-heavy Workers apps under 10 GB, Turso embedded replicas when your runtime has a disk, and Neon when you need real Postgres in one region.
- Only DynamoDB global tables offer multi-Region writes.
On this page
An edge database puts read copies of your data near users so edge functions stop paying a cross-ocean round trip. Writes still go to one primary. Pick Cloudflare D1 for read-heavy Workers apps, Turso embedded replicas when your runtime has local disk, and Neon when you need full Postgres and most users sit in one region.
Verified against
Wrangler 4.156, @libsql/client 0.18, @neondatabase/serverless 1.2, against the Cloudflare D1 limits and read replication docs, the Turso embedded replicas docs, and the Neon read replica, scale-to-zero and connection pooling docs. Checked October 2026.
Why this category exists
Your edge code runs in hundreds of locations; your database usually lives in one region. A Worker in Singapore that queries a primary in us-east-1 is no faster than a Lambda sitting next to that database, because the network hop dominates. There are three ways out:
- Replicate reads to the edge, route writes to a primary (D1 read replication).
- Put a replica inside your process, so reads are local file access (Turso embedded replicas).
- Keep one region but make it serverless and cheap to reach, and move compute near it (Neon).
The three, compared
| Option | Engine | Read path | Write path | Hard limit to know | Best fit |
|---|---|---|---|---|---|
| Cloudflare D1 | SQLite | Replicas in 6 regions (beta) | Single primary | 10 GB per database (paid) | Read-heavy Workers apps |
| Turso embedded replica | libSQL | Local file in your process | Remote primary | Needs a writable filesystem | Long-running servers, mobile |
| Neon | Postgres | Primary or same-region replicas | Single primary | Replicas are same-region only | Full SQL, one main region |
| DynamoDB global tables | Key-value | Local replica per region | Any region (multi-active) | Data model is not SQL | True multi-region writes |
Cloudflare D1: SQLite next to your Workers
D1 is SQLite run by Cloudflare and bound directly into Workers. As of October 2026 the limits page lists 10 GB per database on Workers Paid (500 MB on Free), a 30-second maximum query duration, 100 bound parameters per query, and 1,000 queries per Worker invocation on paid plans. Each database is single-threaded; Cloudflare's own math is roughly 1,000 queries per second at 1 ms per query.
Global read replication is still labeled beta. When enabled, D1 creates replicas in ENAM, WNAM, WEUR, EEUR, APAC and OC at no extra storage or compute charge. Replicas only serve reads through the Sessions API; without it, every query goes to the primary.
npx wrangler d1 create app-db --location=apac
npx wrangler d1 execute app-db --remote --command "CREATE TABLE users (id INTEGER PRIMARY KEY, email TEXT)"
curl -X PUT "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/d1/database/$DATABASE_ID" \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"read_replication": {"mode": "auto"}}'
The Worker carries a bookmark between requests so a user always reads their own writes:
export default {
async fetch(request: Request, env: { DB: D1Database }) {
const bookmark = request.headers.get("x-d1-bookmark") ?? "first-unconstrained";
const session = env.DB.withSession(bookmark);
const { results, meta } = await session
.prepare("SELECT id, email FROM users WHERE id = ?")
.bind(1)
.run();
const res = Response.json({ results, region: meta.served_by_region });
res.headers.set("x-d1-bookmark", session.getBookmark() ?? "");
return res;
},
};
Within a session D1 guarantees sequential consistency: monotonic reads, read-your-writes, and writes that follow reads. Across sessions, a replica can lag. Our longer Cloudflare D1 guide covers migrations and Time Travel.
Turso: libSQL with embedded replicas
Turso hosts libSQL, a SQLite fork. Its embedded replica pattern keeps a SQLite file inside your app that syncs from the remote primary. Reads hit the local file; writes go to the primary and then update the local copy, so the replica that wrote can read its own write immediately. Other replicas see it after their next sync.
import { createClient } from "@libsql/client";
export const db = createClient({
url: "file:/var/data/replica.db",
syncUrl: process.env.TURSO_DATABASE_URL!,
authToken: process.env.TURSO_AUTH_TOKEN!,
syncInterval: 60,
});
await db.sync(); // pull latest frames on startup
const rows = await db.execute("SELECT id, email FROM users LIMIT 10");
The catch is in Turso's own docs: embedded replicas cannot be used in serverless environments without a filesystem, opening the local file while it syncs can corrupt it, and sync is page-based with 4 kB frames, so a one-byte row change still ships 4 kB. For new projects, Turso now points people to Turso Sync, which uses logical change capture with explicit push() and pull(). Running SQLite files in production has its own operational habits; see SQLite in production. For a head-to-head on these two, read Turso vs Cloudflare D1.
Neon: serverless Postgres in one region
Neon is Postgres with storage split from compute, autoscaling, and copy-on-write branches. It is not a multi-region edge database: its read replicas are same-region only, and cross-region copies mean a second project fed by logical replication. What makes it work from edge functions is fast resume and an HTTP/WebSocket driver. Computes scale to zero after 5 minutes idle by default and the docs say they reactivate "within a few hundred milliseconds."
import { neon } from "@neondatabase/serverless";
const sql = neon(process.env.DATABASE_URL!); // use the -pooler hostname
const rows = await sql`SELECT id, email FROM users WHERE id = ${1}`;
For TCP clients, use the pooled endpoint (add -pooler to the endpoint ID). It is PgBouncer in transaction mode with up to 10,000 client connections, which also means no session-level SET, LISTEN/NOTIFY, or SQL-level PREPARE. Run migrations and pg_dump over the direct endpoint. Our PgBouncer pooling guide explains transaction mode in depth.
Errors you will actually see
| Error | Where | Fix |
|---|---|---|
D1_ERROR: no such table: users | D1 | Migration ran locally only; rerun with --remote |
too many SQL variables | D1 | Over 100 bound parameters; batch the insert |
remaining connection slots are reserved for non-replication superuser connections | Neon | Direct endpoint exhausted by functions; switch to -pooler |
prepared statement "s1" already exists | Neon pooled | SQL-level PREPARE through PgBouncer; use driver-level statements |
The quiet failure is a stale read: a write lands on the primary, the next request hits a lagging replica, and the user sees old data. On D1, pass the bookmark; on Turso, read from the replica that wrote or call sync().
Where this breaks
If you need writes accepted in every region with strong consistency, none of the three fits. DynamoDB global tables are multi-active, and since they support multi-Region strong consistency (MRSC) as well as the default eventual mode, they are the managed answer, at the cost of a key-value data model. Heavy SQL also defeats the point at the edge: Workers have tight CPU budgets, and a 200 ms join burns that budget however close the data is. And serverless compute in front of a serverless database means two cold starts, so test from cold. For the wider picture, see choosing the right cloud-native database.
Questions people ask
What is an edge database?
A database that serves reads from locations close to users, usually the same points of presence where edge functions run, instead of from one central region. Writes normally still go to a single primary and replicate outward. Cloudflare D1 with read replication and Turso embedded replicas are examples. The latency win is for reads; write latency still depends on distance to the primary.
Is Cloudflare D1 read replication production ready?
As of October 2026 Cloudflare's docs still label global read replication beta. It adds replicas in six regions at no extra charge, but replicas only serve reads when your Worker uses the Sessions API with withSession(). Without sessions, every query hits the primary. Treat it as a read-latency optimization you can switch off, not a guarantee.
Can Neon replicate across regions?
Not with built-in read replicas: Neon's docs say they are created in the same region as the primary. For another region you create a separate Neon project there and feed it with Postgres logical replication. That works for read-mostly data but gives you two databases to operate, so most teams keep Neon in one region near users.
The call we'd make
Match the database to your compute platform's locality model: one region for writes, replicas for reads. All-in on Workers with a read-heavy dataset under 10 GB, use D1 and pass bookmarks. Running long-lived servers with disks near users, use Turso embedded replicas. Need full Postgres, accept one region and use Neon through the pooler. Multi-region writes are needed far less often than marketing suggests.
Sources
Cite this article
Kiril Urbonas (2026). Edge Databases for Low-Latency Apps: D1, Turso, Neon Serverless. DevOpsNess. Updated 2026-11-15. https://www.devopsness.com/blog/edge-databases-for-low-latency-apps
[Edge Databases for Low-Latency Apps: D1, Turso, Neon Serverless](https://www.devopsness.com/blog/edge-databases-for-low-latency-apps) (Kiril Urbonas, DevOpsNess, updated 2026-11-15)
More from Cloud
Explore more articles in this category
Serverless Architecture Patterns: Building Scalable Applications
We use serverless for specific patterns, not as a default. The patterns where it shines, the ones it doesn't, and the gotchas at production scale.
SigNoz vs Datadog: The Open-Source APM Challenger
Datadog does everything and bills you for all of it. SigNoz covers the core APM story on your own ClickHouse. Here's when the trade is worth it.
The Edge Computing Playbook: What to Run at the Edge (and What Not To)
The edge is fast because it's constrained. This is the decision map for what belongs at the edge, what belongs at origin, and how compute, data, caching, and auth fit together.
You might have missed
Evergreen posts worth revisiting.