# Turso vs Cloudflare D1: Choosing an Edge SQLite Database

URL: https://www.devopsness.com/blog/turso-vs-cloudflare-d1-edge-sqlite
Author: Kiril Urbonas
Published: 2026-06-29
Updated: 2026-11-15
Categories: Cloud
Tags: Edge Computing, Turso, SQLite, Cloudflare, Serverless, Cloudflare D1

Summary: Both put SQLite near your users, but they solve replication and write latency very differently. Here is how the architectures, bills and lock-in compare.

---
# Turso vs Cloudflare D1: Choosing an Edge SQLite Database

Pick Cloudflare D1 if your app already runs on Workers; pick Turso if you want reads served from a local SQLite file, a database per tenant, or an exit from one vendor. Both route every write to a single primary, so neither makes global writes fast. The difference is where reads happen and what you are locked into.

> [!VERIFIED]
> Cloudflare D1 (Workers Free and Paid plans), Turso Free and Developer plans, libsql Python client, against the Cloudflare D1 pricing, limits and read replication docs and the Turso pricing and embedded replica docs. Checked October 2026.

## The architectures diverge on where reads come from

D1 is Cloudflare's managed SQLite. A database has one primary where writes land, and read replication serves reads from replicas in other regions while the primary replicates out asynchronously. You turn replication on per database (dashboard or REST API), and your Worker must use the Sessions API or every query still goes to the primary. Cloudflare's pricing page states replicas carry no extra charge; you pay the same rows-read and rows-written rates. You talk to D1 through a Worker binding, not a wire protocol, so D1 assumes you live inside the Workers runtime.

```javascript
// src/index.js
export default {
  async fetch(request, env) {
    const bookmark = request.headers.get("x-d1-bookmark") ?? "first-unconstrained";
    const session = env.DB.withSession(bookmark);
    const { results } = await session
      .prepare("SELECT enabled FROM flags WHERE key = ?")
      .bind("checkout_v2")
      .all();
    const res = Response.json(results);
    res.headers.set("x-d1-bookmark", session.getBookmark() ?? "");
    return res;
  },
};
```

Turso is built on libSQL, an open fork of SQLite. Its model is embedded replicas: your application holds a full local copy of the database on disk, reads hit that file, and writes go to a remote primary. You connect with a normal client library from any server or container that has a filesystem.

```python
# app.py  (pip install libsql)
import os
import libsql

conn = libsql.connect(
    "flags.db",
    sync_url=os.getenv("LIBSQL_URL"),
    auth_token=os.getenv("LIBSQL_AUTH_TOKEN"),
)
conn.sync()  # pull latest frames from the primary
rows = conn.execute(
    "SELECT enabled FROM flags WHERE key = ?", ("checkout_v2",)
).fetchall()
```

Once synced, reads never cross the network. A local file read beats any network round trip, however close the replica is.

## Write latency and consistency

Neither makes writes free. Both have a single write primary, so a write from the far side of the world pays a round trip to wherever that primary lives. An embedded replica does not change this; per Turso's docs, writes go to the remote primary by default and are not written to the local file first.

Consistency is where they differ in detail. Turso's docs say the replica that made a write sees it immediately, without calling `sync()`; every other replica stays stale until it syncs or hits its `syncInterval`. D1 replicas lag the primary too, and the Sessions API handles it: `withSession("first-primary")` sends the first query to the primary, and passing a bookmark between requests (the `x-d1-bookmark` header above) keeps a user's reads ordered after their own writes. Both make you think about consistency; neither hides it.

One cost detail from Turso's embedded replica docs: syncs move 4 kB frames, so a one-byte row change still produces a 4 kB write to sync. Sync volume is billed on paid plans.

## Pricing and the shape of the bill

Both bill on rows read, rows written, and storage, but the free tiers reset on different clocks: D1 per day, Turso per month.

| Plan (as of October 2026) | Price | Rows read | Rows written | Storage | Databases |
|---|---|---|---|---|---|
| D1 Free | $0 | 5M per day | 100K per day | 5 GB total, 500 MB per DB | 10 |
| D1 on Workers Paid | Workers Paid plan | 25B/month, then $0.001 per M | 50M/month, then $1.00 per M | 5 GB, then $0.75/GB-month; 10 GB per DB | 100,000 included, up to 1M |
| Turso Free | $0 | 500M per month | 10M per month | 5 GB | 100 |
| Turso Developer | $4.99/month, billed yearly | 2.5B, then $1 per B | 25M, then $1 per M | 9 GB, then $0.75/GB | Unlimited |

Watch rows-read billing on both: an unindexed lookup that scans a big table on every request multiplies "rows read" by the table size, and that is the classic way an edge SQLite bill spikes. On D1 Free, hitting the daily read or write cap blocks queries until the daily reset rather than billing overage. Turso's unlimited databases on paid plans make database-per-tenant cheap, which matters for multi-tenant SaaS where each customer wants isolation.

## Lock-in and portability

D1 only runs on Cloudflare, and your access path is tied to Workers. `wrangler d1 export` gives you a SQL dump if you ever want out.

Turso is libSQL, open source, and self-hostable, and the embedded replica is a SQLite file you can copy. For one database reachable from a Fly.io box, a Lambda, and a Worker, Turso is the less trapped choice.

## Operational differences you notice in month two

**Migrations.** D1 has a migrations system wired into Wrangler, tracked in a `d1_migrations` table, so schema changes ride along with your Worker deploy:

```
$ npx wrangler d1 migrations create flags-db add_flags_table
$ npx wrangler d1 migrations apply flags-db --local
$ npx wrangler d1 migrations apply flags-db --remote
```

Turso expects you to bring your own migration tool pointed at a libSQL URL.

**Backups.** Both offer point-in-time restore; Turso's window is 1 day on Free and 10 days on Developer.

**Local development.** Turso wins: an embedded replica already is a local file. D1 local development goes through Wrangler's simulated environment, which is good and is still a simulation. More D1 specifics are in our [Cloudflare D1 guide](/blog/cloudflare-d1-guide).

## Failure modes and the fix for each

- **`D1_ERROR: no such table: flags` in production but not locally:** you applied migrations with `--local` only. Run `wrangler d1 migrations apply flags-db --remote`.
- **D1 reads return stale rows right after a write:** replication is on but you are not passing a bookmark. Thread `getBookmark()` through the client as shown above, or use `"first-primary"` for that request.
- **D1 Free queries start failing mid-day:** the 5M rows-read or 100K rows-written daily cap. Add an index or move to Workers Paid.
- **Turso embedded replica crashes in Workers or another edge function:** Turso's docs state embedded replicas cannot run in serverless environments without a filesystem. Use the fetch-based `@tursodatabase/serverless` client there.
- **Turso local file corrupted after a crash:** the docs warn not to open the local database while it is syncing. Delete the local files and let it re-sync from scratch.

## Where this breaks

Both solve one shape of problem: read-heavy workloads that want low latency in many regions, with modest writes and tolerance for replica lag. If your users sit in one region, a single Postgres instance with a pooler is faster to build and cheaper. If writes are heavy or must be visible everywhere at once, the single-primary model becomes the constraint. The broader category, including Postgres options like Neon, is covered in [edge databases for low-latency apps](/blog/edge-databases-for-low-latency-apps).

## Questions people ask

### Is Turso SQLite at the edge?

Yes. Turso runs libSQL, an open-source fork of SQLite, and gets its edge behavior from embedded replicas: each app instance keeps a full local copy of the database and reads it as a file, while writes go to one remote primary. Edge runtimes without a filesystem, such as Cloudflare Workers, can't host an embedded replica and connect to Turso remotely instead.

### Turso vs D1: which is cheaper?

For small apps, both are free: D1 allows 5 million rows read and 100,000 rows written per day, Turso 500 million read and 10 million written per month, each with 5 GB of storage as of October 2026. Turso's paid tier starts at $4.99 a month on yearly billing; D1 paid usage rides on the Workers Paid plan. Query shape matters more than list price, since both bill per row scanned.

### Can I use Turso from Cloudflare Workers?

Yes, but not with embedded replicas. Turso's docs point edge runtimes, Cloudflare Workers included, at the fetch-based `@tursodatabase/serverless` package, which queries the remote database on each request. You lose the local-file read path that makes Turso fast elsewhere, so on Workers D1 is usually the better fit unless you need Turso's portability or database-per-tenant model.

## The decision, concretely

- Already building on Cloudflare Workers? Use D1. The binding is the ergonomic win, and read replicas cost nothing extra.
- Read-dominated with a hard latency target, on servers or containers with a disk? Use Turso. Embedded replicas take the network out of the read path entirely.
- Multi-tenant SaaS where each customer wants isolation? Turso, with unlimited databases on paid plans.
- New to Turso? The [Turso setup walkthrough](/blog/turso-tutorial) covers the CLI, credentials, and a local embedded replica.

## The call we'd make

If your stack already lives in Cloudflare Workers, use D1: the binding just works and replication is free. If you're read-dominated and want true local-file reads, database-per-tenant, or a self-hosting exit, use Turso. Our default for a service running on ordinary servers is Turso; for anything already deployed as a Worker it is D1, without hesitation.

## Sources

- [Cloudflare D1 pricing](https://developers.cloudflare.com/d1/platform/pricing/)
- [Cloudflare D1 global read replication and Sessions API](https://developers.cloudflare.com/d1/best-practices/read-replication/)
- [Turso pricing](https://turso.tech/pricing)
- [Turso docs: embedded replicas](https://docs.turso.tech/features/embedded-replicas/introduction)

