---
title: "Under the hood, off the hot path: How D1 scales to millions of databases"
description: "D1, Cloudflare’s serverless SQLite database, has seen 15x growth in live databases over the past year and scales by keeping query execution on the edge in Durable Objects, separate from the control plane’s metadata operations. The control plane uses an Edge API Worker with Hyperdrive to access Postgres clusters for transactional metadata, while Workers KV caches database-to-Durable-Object mappings for fast edge lookups. Database creation completes in about 1.6 seconds by generating a Durable Object ID, persisting metadata to Postgres, and storing the mapping in Workers KV, with the Durable Object lazily initialized on first query. Storage usage enforcement uses atomic counters in Workers KV that are checked locally on each query and updated asynchronously after execution, avoiding any central database round trip during the query. Precomputed aggregations for billing are stored in ClickHouse, and guiding principles such as eventual consistency and idempotency further reduce reliance on centralized components."
---

# Under the hood, off the hot path: How D1 scales to millions of databases

[Cloudflare](https://yomu.fyi/company/cloudflare) · Lambros Petrou · Oct 13, 2026

**Type:** Explainer

## Summary

D1, Cloudflare’s serverless SQLite database, has seen 15x growth in live databases over the past year and scales by keeping query execution on the edge in Durable Objects, separate from the control plane’s metadata operations. The control plane uses an Edge API Worker with Hyperdrive to access Postgres clusters for transactional metadata, while Workers KV caches database-to-Durable-Object mappings for fast edge lookups. Database creation completes in about 1.6 seconds by generating a Durable Object ID, persisting metadata to Postgres, and storing the mapping in Workers KV, with the Durable Object lazily initialized on first query. Storage usage enforcement uses atomic counters in Workers KV that are checked locally on each query and updated asynchronously after execution, avoiding any central database round trip during the query. Precomputed aggregations for billing are stored in ClickHouse, and guiding principles such as eventual consistency and idempotency further reduce reliance on centralized components.

## Approach / What changed

The D1 control plane was redesigned by separating query execution (data plane) into Durable Objects at the edge, while the control plane uses an Edge API Worker with Hyperdrive to central Postgres for metadata. Workers KV caches routing data for fast lookups. Background analytics and billing run asynchronously on ClickHouse with precomputed aggregations. Storage limits are enforced via atomic counters in Workers KV updated asynchronously.

## Takeaways

- D1 uses one SQLite Durable Object per database, enabling millions of independent databases to run at the edge without a shared server.
- The control plane avoids query hot-path bottlenecks by caching database-to-Durable-Object mappings in Workers KV and using Hyperdrive for connection pooling to central Postgres.
- Storage usage limits are enforced via atomic counters in Workers KV that are checked locally before each query and updated asynchronously after execution, avoiding central database round trips.

## FAQ

### How does D1 create a database so quickly?

Database creation takes about 1.6 seconds because it generates a Durable Object ID, persists metadata to Postgres, and writes the mapping to Workers KV for edge caching. The Durable Object is not created synchronously; it is lazily initialized on the first query.

### How does D1 enforce storage limits without slowing queries?

Storage usage is tracked via atomic counters in Workers KV that are updated asynchronously after query execution. On each query, the Worker checks the cached counter locally, and if the limit is exceeded, the query is rejected without any round trip to a central database.

### How does D1 separate control plane from data plane?

The data plane (query execution) runs entirely at the edge in Durable Objects via the Eyeball Worker, while the control plane (create, delete, list) uses the Edge API Worker with Hyperdrive to access central Postgres clusters. Background analytics and billing run asynchronously on ClickHouse.

**Tags:** [Architecture](https://yomu.fyi/topic/architecture), [D1](https://yomu.fyi/topic/d1), [Edge Computing](https://yomu.fyi/topic/edge-computing), [Serverless](https://yomu.fyi/topic/serverless), [SQLite](https://yomu.fyi/topic/sqlite)

- Source: [Cloudflare](https://blog.cloudflare.com/d1-control-plane)
- Source URL: https://blog.cloudflare.com/d1-control-plane
- Ingested by Yomu: 2026-10-13T18:00:17.529Z

[Read original post](https://blog.cloudflare.com/d1-control-plane)
