Cloud & infrastructure

How Cloudflare D1 scales to millions of serverless SQLite databases

Cloudflare rearchitected its D1 control plane to support millions of per-user SQLite databases, using edge caching and heartbeats to avoid centralized bottlenecks.

Illustration of distributed database nodes spreading from a central point
Illustration generated for this article

Cloudflare has significantly expanded the scale of its D1 serverless database service to support architectures that require millions of individual database instances. Published on October 13, 2026, this architectural update details how the company modified its control plane to handle a 65x growth in live databases over two years without degrading query performance for active users.

What happened

The shift toward AI-assisted development and multi-tenant platforms has changed how developers structure data. Instead of relying on one or two large database clusters with connection pooling, modern applications often create small, isolated databases for each user, preview environment, or tenant. This model aligns well with D1, which is built on SQLite, but it presents a massive scaling challenge for the control plane that manages database creation and metadata.

To address this, Cloudflare implemented a series of architectural changes designed to keep query operations off the hot path of centralized systems. The goal was to allow platforms to create millions of databases while ensuring that only the active ones consume significant resources. As of October 8, 2026, D1 saw an 18x growth in daily active databases over the previous year, validating the need for a system that could distinguish between created and actively used instances efficiently.

These changes were driven by real-world usage from large platforms building on Cloudflare’s developer tools. For example, Jon Abrams from ChatGPT Sites noted that D1 allows their users to add features like leaderboards and comments in a scalable way. To ensure reliability during this expansion, Cloudflare periodically load-tested the system against targets well above expected growth, focusing optimization efforts on the bottlenecks revealed by these realistic workloads.

How it works

The core of D1’s architecture relies on separating the data plane, which handles queries, from the control plane, which manages database lifecycle events. Each D1 database is backed by a single SQLite Durable Object, making it easy to instantiate millions of them. However, querying a central database for metadata on every request would create unacceptable latency. To solve this, Cloudflare uses Workers KV, a globally distributed key-value store, to cache critical routing metadata at the edge. This ensures that cache misses rarely need to query central databases, keeping query requests fast and localized.

For control plane operations like creating or deleting databases, the system uses Hyperdrive to access central Postgres databases efficiently. Hyperdrive provides connection pooling and optimized routing, allowing the Edge API Worker to interact with Postgres read replicas for most checks. When a user creates a database, the system generates a unique ID and initializes the underlying Durable Object near the user’s location. It then persists this mapping in Postgres and updates Workers KV. This process includes retry logic to handle failures, ensuring that even if a step fails, the system can self-correct without leaving orphaned resources.

A key mechanism for maintaining consistency is the heartbeat system. Each Durable Object periodically sends a heartbeat to the control plane every 30 seconds to check its status and account limits. If a database was deleted in Postgres but the Durable Object still exists due to a previous error, the heartbeat response will indicate that the database no longer exists. The Durable Object then marks itself as deleted, cleaning up orphaned resources automatically. This eventual consistency model allows the system to remain available and reliable without requiring strong consistency for every operation.

Key details

  • D1 experienced a 65x growth in live non-deleted databases over the past two years as of October 8, 2026.
  • Daily active databases grew 18x over the past year, highlighting the difference between created and used instances.
  • Workers KV is used at the edge to cache routing metadata, reducing the need for central database queries during data plane operations.
  • Hyperdrive enables efficient connection pooling and routing to central Postgres databases for control plane tasks.
  • Each D1 database is backed by a single SQLite Durable Object, allowing for massive scale and isolation.
  • A 30-second heartbeat mechanism allows Durable Objects to self-correct their state based on the source of truth in Postgres.

Why it matters

For software engineers building multi-tenant applications or AI agents, this architecture demonstrates how to scale beyond traditional monolithic database patterns. The ability to create millions of small, isolated databases without managing connection pools or worrying about centralized bottlenecks opens new possibilities for application design. Developers can now assign a dedicated database to each user or session, improving security and data isolation without sacrificing performance.

The separation of data and control planes also offers a blueprint for building resilient distributed systems. By using eventual consistency and edge caching, developers can reduce latency and increase availability. The heartbeat pattern, in particular, provides a robust way to handle failures and clean up resources without complex transactional logic. This approach is especially relevant for those building on serverless platforms where resource efficiency and automatic scaling are critical.

What you can do

  • Design your application to use one database per tenant or user if data isolation is a priority, leveraging D1’s ability to scale to millions of instances.
  • Use Workers KV to cache frequently accessed metadata at the edge, reducing latency and load on your central database.
  • Implement heartbeat mechanisms in your distributed systems to allow components to self-correct their state based on a central source of truth.
  • Use Hyperdrive or similar connection pooling tools to optimize access to central databases for control plane operations.
  • Load-test your system with realistic workloads to identify bottlenecks in your control and data planes before they impact users.
  • Embrace eventual consistency for non-critical operations to improve system availability and reduce complexity.
  • #cloudflare
  • #d1
  • #serverless
  • #sqlite
  • #architecture
  • #scaling

Tools from the Bytechap store

Keep reading

All stories