Self-host Workers and Durable Objects with workerd clustering (experimental)
You can now run Workers and Durable Objects as a multi-machine cluster on your own infrastructure with workerd ↗︎, the open-source runtime behind Cloudflare Workers. Until now, workerd was primarily for local development because it ran as a single instance and stored data only on a local disk. Now several workerd instances can form one cluster that shares an object storage bucket. Documentation is at workerd.dev ↗︎.
- Your own infrastructure: Run inside your VPC, Kubernetes cluster, or on-premises hardware, next to internal services or within data residency limits.
- Stateful AI agents: Give each agent a Durable Object with SQLite memory and alarms. Idle agents are evicted from memory; their state stays in the bucket.
- Real-time apps: Give each chat room or collaborative document its own SQLite database, without a shared database or message broker.
- Coordination: Build locks, counters, and job schedulers, each a single Durable Object that every instance routes to.
Point multiple workerd instances at an object storage bucket that supports conditional writes — such as Cloudflare R2, Amazon S3, or Google Cloud Storage. workerd persists each Durable Object SQLite database in the bucket and uses conditional writes to choose one leader for each object, with no consensus service.
Any instance can accept a request for any object and forward it to the object's leader. To add capacity, start another instance against the same bucket. When an instance stops or fails, another instance takes over its objects without losing acknowledged writes.
workerd now reads wrangler.json and wrangler.jsonc directly, so an existing Workers project that uses only the supported configuration keys ↗︎ runs on your own machines unchanged. (Soon workerd will also read worker.config.json, using the schema that the cf command writes, in place of wrangler.json. Refer to limitations ↗︎ for other changes that are coming soon.)
npx workerd serve .
yarn workerd serve .
pnpm workerd serve .
For Docker or Kubernetes, every workerd release publishes the docker.io/cloudflare/workerd image for linux/amd64 and linux/arm64:
The image has no esbuild, so set "no_bundle": true and make main an ES module that is already bundled.
Previously, workerd natively supported only Workers and Durable Objects. You needed Miniflare and Wrangler to run projects that used D1, Workflows, and other services. Now more of the Cloudflare stack is built into the single workerd binary. Like the cluster support itself, these built-in services require --experimental. (In a cluster, KV and Queues still need a Cap'n Proto configuration, config.capnp; wrangler.json support is coming soon.)
| Service | Status | Cluster support | |---|---|---| | Workers | Supported | Yes | | Durable Objects | Supported | Yes | | Durable Object Facets | Supported | Yes | | D1 | Experimental | Yes | | R2 | Experimental | Yes | | Workflows | Experimental | Yes | | Cron Triggers | Experimental | Yes | | Static Assets | Experimental | Yes | | Cache API | Experimental | Yes | | Rate Limits | Experimental | Per-instance | | KV | Experimental | Yes ( config.capnp ) | | Queues | Experimental | Yes ( config.capnp ) |
Clustering requires --experimental. Start each instance with the same bucket and the same cluster key, at least 32 bytes, and its own cluster address:
For R2 or S3, also set AWS_ENDPOINT_URL, AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY; refer to the cluster guide ↗︎.
A cluster is meant to run a single application whose code you trust. workerd is not a hardened sandbox. For details, refer to security ↗︎.
We're just getting started with workerd clustering; the purpose of this experimental release is to gather feedback. Please open issues in github.com/cloudflare/workerd ↗︎ as you encounter them.
For more information, refer to the workerd documentation ↗︎, including the cluster guide ↗︎, Cloudflare compatibility ↗︎, guarantees ↗︎, and limitations ↗︎.