Definition
Durable Objects are a stateful coordination primitive within the Cloudflare Workers platform. Each Durable Object is a named, single-threaded JavaScript object that runs in a V8 isolate at the Cloudflare edge, maintains persistent state through a built-in transactional key-value storage API, and can hold open WebSocket connections. Unlike stateless Workers (which spin up and terminate per request), a Durable Object persists as long as it has active connections or recent activity, then hibernates—resuming on the next incoming request.
The critical property is uniqueness: each Durable Object is identified by a globally unique ID, and the Cloudflare runtime guarantees that exactly one instance of a given object exists at any time, anywhere in the global network. This single-writer guarantee eliminates the distributed consensus problems that plague stateful edge systems.
Why It Matters
Edge computing platforms like Cloudflare Workers, Fastly Compute, and Vercel Edge Functions excel at stateless request processing but historically struggled with stateful workloads—real-time collaboration, chat, gaming, IoT coordination—because those workloads require a single source of truth that multiple clients can read from and write to simultaneously.
Traditional solutions route these workloads back to centralized databases (Postgres, Redis, DynamoDB), sacrificing the latency benefits of edge computing. A chat application serving users in Tokyo, London, and Sao Paulo would process messages at edge PoPs in under 20ms but then write state to a database in us-east-1 with 150-300ms round-trip latency.
Durable Objects solve this by colocating stateful coordination with one of the connected clients. Cloudflare automatically places the Durable Object instance in the data center closest to where it was first created (or where the majority of its traffic originates). Cloudflare reports sub-millisecond read/write latency for Durable Object storage operations, since the storage is local to the isolate.
As of 2024, Durable Objects power production workloads at scale: Cloudflare’s own products (R2, Queues, D1) use Durable Objects internally, and thousands of applications use them for WebSocket coordination, rate limiting, and session management.
How It Works
Durable Objects operate through several mechanisms:
Identity and routing: Each Durable Object has a unique ID (either derived from a name string or randomly generated). When a Worker wants to communicate with a Durable Object, it obtains a stub using the ID, and Cloudflare’s routing layer directs the request to the single global instance of that object.
Single-threaded execution: All requests to a given Durable Object are serialized—processed one at a time, in order. This eliminates race conditions and makes state mutations deterministic without requiring locks, transactions, or conflict resolution.
Transactional storage: Each Durable Object has access to a private key-value storage API with strong consistency guarantees. Reads see the latest write. Storage operations can be batched into atomic transactions. Data is automatically persisted to durable storage with replication.
WebSocket support: Durable Objects can accept and hold WebSocket connections, enabling real-time bidirectional communication. Multiple clients connect to the same Durable Object, which serves as the coordination point for shared state.
Hibernation: When a Durable Object has no active connections or pending requests, it can enter a hibernation state that releases its V8 isolate from memory while preserving its durable storage. On the next request, it rehydrates within milliseconds.
Stealth Cloud Relevance
Stealth Cloud uses Durable Objects for Ghost Chat’s real-time session state: managing active WebSocket connections during a chat session, coordinating streaming responses from LLM providers, and maintaining the ephemeral session context (model selection, burn timer state, message count) for the duration of the conversation.
The architectural alignment is precise. Durable Objects are stateful, but their state is bounded by the session lifecycle. When the burn timer expires or the user explicitly destroys a session, the Durable Object is deleted—its storage is wiped, its isolate terminated, its unique ID invalidated. This makes Durable Objects the stateful complement to stateless Workers in Stealth Cloud’s ephemeral infrastructure: they hold state exactly as long as it is needed and are destroyed when it is not.
No centralized database is involved. No session state is written to a persistent datastore that outlives the session. The Durable Object is the session, and when the session ends, the object ceases to exist.
Related Terms
The Stealth Cloud Perspective
Durable Objects solve a paradox: how do you maintain real-time session state in an architecture that refuses to persist anything? The answer is state with a built-in expiration date—objects that exist precisely as long as the conversation they coordinate, and that are annihilated the moment that conversation ends.