Durable Objects
Cloudflare’s single-instance objects with their own storage: one place in the world that owns a piece of state.
Durable Objects are Cloudflare’s single-instance objects with their own storage: each one is the single place in the world that owns a piece of state, such as a chat room or one customer’s budget. Every request for that object reaches the same instance.
Each object has a unique id, runs in one location at a time on a single thread, and its storage operations are protected from interleaving, so state races are far easier to avoid; requests can still interleave while one awaits an outside call. That makes it a natural fit for a chat room, a game lobby, a document being edited together, a counter or a budget that must never be overspent. Objects can hold WebSocket connections and wake up on alarms. The Durable Objects docs describe the limits and pricing.
They suit coordination, where two users acting at once must see one truth: an authoritative server for a game match, or the counter behind a cost cap. Because one object handles its work on a single thread, one global object for everything becomes a bottleneck. Compared with a stateless edge function, the object keeps state between requests and can push live updates to clients over WebSockets or server-sent events.
Sources
- Cloudflare: Cloudflare Durable Objects developers.cloudflare.com
Related terms
- Edge computing (Workers): Running code in data centers close to the user, on the CDN, instead of in one central region.
- Server-Sent Events (SSE): A standard way for a server to push a stream of updates to the browser over one long HTTP response.
- Authoritative server (netcode): In multiplayer games, the server decides the true game state; clients only send inputs and predict what will happen.
- Cost cap: A hard spending limit enforced by your code, per user, per day or per month.
- Optimistic locking: Detecting conflicting edits with a version number: a save succeeds only if the record has not changed since it was read.
