Skip to content

Durable Objects

Use native Durable Objects when one Worker needs named, stateful coordination with SQLite storage, alarms, RPC, or WebSockets. Deploy them through Wrangler in the same project as their owning Worker; no platform-specific deployment command or Ansible application role is involved.

Deploy a namespace

Declare the binding and migration in wrangler.jsonc:

{
  "name": "durable-counter",
  "main": "src/index.js",
  "compatibility_date": "2026-09-30",
  "durable_objects": {
    "bindings": [{ "name": "COUNTERS", "class_name": "Counter" }]
  },
  "migrations": [
    { "tag": "v1", "new_sqlite_classes": ["Counter"] }
  ]
}

Export Counter from the Worker module and deploy normally with wrangler deploy. Wrangler reads the active migration tag from the control plane, uploads the next immutable Worker version, and submits the required namespace migration. The platform validates the complete native workerd configuration before making that version active.

The current migration surface supports new_sqlite_classes and renamed_classes. Namespace deletion, class transfer, legacy key-value-backed classes, and cross-Worker namespace bindings are rejected explicitly. Use a same-organization service binding when another Worker needs to call the owning Worker.

Runtime behavior

Stateful Workers use native workerd Durable Object namespaces with SQLite enabled. Native object addressing, RPC, transactional storage, SQL, alarms, and WebSockets execute inside workerd. The platform does not emulate the namespace API or intercept object methods.

Objects receive the owning Worker’s declared resource bindings, including AI and TELEMETRY. Application telemetry emitted from an object is attributed to that Worker and deployment, with the same organization scope and metering as ordinary Worker events.

Each stateful application receives a stable assignment to a shared runtime member. Its objects retain their state across deployments and restarts. The runtime hosts many applications and objects; there is no dedicated process or VM per object. New Workers with ordinary Durable Object bindings use the clustered storage engine by default. Existing applications keep their recorded placement; adding capacity or updating the runtime does not move their state. An operator can explicitly migrate an ordinary application from its standalone member into clustered storage. That controlled operation freezes writes and alarms, copies and verifies the complete namespace cohort with the same identities and migration tag, persists the new placement, and then resumes the application. Tenant bindings, names, routes, and Wrangler deployment behavior do not change. Operators use the read-only inventory and exact-target workflow documented in Platform operations; there is no implicit or bulk cutover.

New compatible Workers that declare Workflows also use clustered storage by default. An explicit migration of an existing Workflow Worker treats the runtime-owned Workflow engine namespace and that Workflow’s exact actor in the shared platform journal as one physical cohort. The operation preserves pending waits, instance identity, lifecycle evidence, and subsequent Wrangler deployments without copying unrelated journal actors. It uses the same exact-target operator workflow as an ordinary Durable Object migration; there is no implicit or bulk cutover.

Cron coordination uses a separate platform-owned namespace on clustered storage even when the owning Worker has no application Durable Objects. During the clustered-storage cutover, the platform freezes every source coordinator for an organization, consolidates and verifies the complete schedule, pause, suspension, lease, and outcome state, commits every Worker placement together, and only then activates the destination coordinator. The migration is resumable and does not change a tenant’s Cron definitions or Wrangler workflow. Operators can exclude one exact organization/Worker from the clustered default when rehearsing migration or containing a compatibility issue.

The currently deployed clustered profile uses one member, so it does not replicate application state or provide automatic failover. The service remains single-region and non-HA. Operators manage placement and persistence through Platform operations.

The same native shard substrate also hosts platform-owned Cron coordinator objects. There is one coordinator object per organization in clustered storage; its SQLite state, alarm, delivery lease, suspension state, and retry schedule replace the former control-plane polling loop. This reuse is deliberately below the service-semantics boundary: application Durable Objects and Cron retain separate schemas and APIs.

Queues already use workerd Durable Objects for their broker state, alarms, leases, retries, retention, and dead-letter transitions. That proven queue state machine remains owned by the queue service and runs in its dedicated workerd service on platform-owned clustered storage. Registry, broker, and telemetry namespaces migrate as one verified cohort. It is not reimplemented through the application namespace API or collapsed into a generic coordinator object. The current queue cluster has one member and is not an HA replica set.

Execution budgets

The Worker project’s limits.cpu_ms and limits.subrequests also govern its Durable Object events. The defaults are 100 ms of active JavaScript CPU and 50 subrequests; accepted declarations can raise them to 5,000 ms and 1,000 subrequests. Waiting for network or storage I/O does not consume active CPU time. Native incoming events replenish the object’s budget; it is not a cumulative lifetime allowance for that object.

A CPU violation fails the invocation and discards the affected object’s in-memory instance. A subsequent invocation constructs a new instance using its committed storage. Do not rely on uncommitted writes or in-memory changes surviving a failed event. Sibling objects and the shared shard process do not need to restart for this CPU recovery. Failed alarms retain workerd’s native retry behavior; application operations should be safe to retry.

This does not provide dedicated CPU capacity. A long permitted JavaScript turn or native SQLite statement can delay other work in the shared process until its budget expires. Native actor SQL observes that same budget through a SQLite progress handler and an interrupted object is reconstructed from committed state. Static Worker memory exhaustion still lacks independent isolate recovery. See Runtime isolation for the operator boundary.

Deployments and operations

Platform contributors can run make durable-objects-native-test PROFILE=single against a provisioned local appliance. Ansible uses the installed enforcing runtime and an isolated temporary test workspace to check SQLite persistence, workflow recovery, Cron, and native AI/telemetry bindings without accessing application stores.

A code update preserves namespace identities and their SQLite files. Applying a namespace migration is an optimistic transition from Wrangler’s observed migration tag. The shard manager encrypts staged application bundles, records cutover intent in SQLite, validates the candidate configuration, and restores the last committed configuration after an interrupted or failed cutover.

Workerd owns each SQLite namespace through one process at a time, so the current implementation performs a stop-before-start shard cutover. Applications sharing that member can see a brief interruption during an update; the platform does not claim zero-downtime Durable Object deployments yet. Lifecycle events and cutover duration are recorded for the Worker.

In the tenant console, open Compute → Durable Objects to browse all of your organization’s application namespaces. Filter by class or owning Worker, then open a namespace to inspect its identity, assigned member, migration tag, stored object databases, and storage usage. Lifecycle shows paginated deployment and recovery events for the owning Worker. Filters and page selections are bookmarkable. A stateful Worker’s View Durable Objects link opens this inventory already filtered to that Worker.

Organization Durable Object namespace inventory

Stored object counts describe persisted databases, not running instances. The inventory excludes the platform’s internal Cron and queue coordination objects. Class definitions and migrations remain in Wrangler; there is no console action to delete a namespace or move its state between hosts.

Platform operators see shard process health and resource pressure with the rest of the selected data host in Platform → Fleet.

Namespace holdings are enforced through the quota service before growth. A Free organization starts with three namespaces, Standard with 20, and Enterprise with 100 unless an explicit support override applies. Reducing a limit does not delete state; it prevents further namespace growth while usage remains over the limit.

Example application

The durable counter demonstrates named state, RPC, alarms, and WebSockets. It is included in the self-hosted local example set. Its Wrangler configuration uses the same APIs available to your own organization.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close