Cloudflare Durable Objects: Stateful Coordination at the Edge
Edge functions run everywhere and remember nothing. Durable Objects give you one addressable, single-threaded instance with transactional storage, the missing source of truth.
Key takeaways
- A Cloudflare Durable Object is a single-threaded, globally unique instance with its own strongly consistent storage.
- Every request for the same name reaches the same instance, so counters, rate limits, chat rooms and locks stop racing across locations.
- Use them for coordination, not read caching, and shard hot keys past about 1,000 requests per second.
On this page
A Cloudflare Durable Object is one named, single-threaded instance with its own transactional storage. Every request for that name, from any location, reaches the same instance, so anything needing one true answer (a counter, rate limit, room, or lock) stops racing. Use them for coordination; keep read-heavy caching in KV, and shard any key that outgrows one object.
Verified against
Cloudflare Workers and Durable Objects with SQLite-backed storage, against the developers.cloudflare.com Durable Objects overview, get-started, rules, limits and pricing pages. Checked October 2026.
We had a rate limiter that let through roughly triple the traffic it was supposed to. The logic was fine. The problem was that our limiter counted requests in a Worker, and Workers run in whatever point of presence is closest to the user. A burst from a single client hitting three different PoPs got counted three separate times, each below the threshold, none the wiser. Nothing was broken. There was just no single place that knew the real number.
That is the shape of every edge state problem. Edge functions are stateless by design and run in hundreds of locations at once, which is exactly why they're fast. But anything that needs one true answer (a counter, a rate limit, a chat room's member list, a lock, who owns a WebSocket connection) races the moment you spread it across PoPs. You can push the truth back to a central database, but then you've paid a round trip to a single region and thrown away the reason you went to the edge.
What a Durable Object actually is
A Durable Object is one instance, identified by a name or ID, that lives in exactly one place at a time. Every request addressed to that name routes to that same instance, no matter which PoP it came from. Cloudflare's docs describe each one as "a single-threaded, globally-unique instance with its own persistent storage," so inside it you reason about state the way you would in a normal program. Input gates stop new events from interleaving while storage operations run, and output gates hold responses until pending writes are persisted, so clients never see data that could be lost.
That combination is the whole trick. The counter that was racing across PoPs becomes a single object addressed by client IP. All three requests from that burst route to the same instance, get serialized, and see the same number. The race is gone because there is now exactly one thing doing the counting.
Objects are created lazily the first time you call a method on a stub for a name, hibernate when idle, and wake up with their storage intact. As of October 2026 the docs recommend SQLite-backed storage for every new class; it supports both SQL and a key-value API, and it is the only kind available on the Workers Free plan.
Where they earn their keep
Real-time collaboration is the clean fit: one object per document or room holds the live state and fans updates out to connected clients, and WebSocket Hibernation is the documented way to hold many client connections without keeping the object busy. Per-user or per-tenant state (a session, a shopping cart, a game lobby) maps to one object per user. Distributed locks and leader election work because single-threaded access is a mutex you didn't have to build. Coordination in general: anything where you'd otherwise reach for Redis and a lot of hope. If what you actually need is a relational database shared across many Workers, that is Cloudflare D1, not a Durable Object.
A Worker plus a Durable Object
Here's the rate limiter, rebuilt as an object. The class extends DurableObject from cloudflare:workers, holds a fetch handler, and reads and writes through this.ctx.storage.
// src/rate-limiter.ts
import { DurableObject } from "cloudflare:workers";
export class RateLimiter extends DurableObject<Env> {
async fetch(request: Request): Promise<Response> {
const now = Date.now();
const windowMs = 60_000;
const limit = 100;
// Storage is local to this instance, so the read is fast.
let hits = (await this.ctx.storage.get<number[]>("hits")) ?? [];
hits = hits.filter((t) => now - t < windowMs);
if (hits.length >= limit) {
return new Response("rate limited", { status: 429 });
}
hits.push(now);
await this.ctx.storage.put("hits", hits);
return new Response("ok", { status: 200 });
}
}
The Worker in front of it gets a stub by name and forwards the request:
// src/index.ts
export { RateLimiter } from "./rate-limiter";
export default {
async fetch(request: Request, env: Env): Promise<Response> {
const ip = request.headers.get("cf-connecting-ip") ?? "anon";
const stub = env.RATE_LIMITER.getByName(ip);
return stub.fetch(request);
},
};
interface Env {
RATE_LIMITER: DurableObjectNamespace;
}
getByName(ip) is the important line: the same IP always maps to the same object, so every request from that client lands on one instance. (The older two-step form, idFromName(ip) then get(id), does the same thing.) The binding and the migration that registers the class as SQLite-backed live in the Wrangler config:
# wrangler.toml
name = "edge-limiter"
main = "src/index.ts"
compatibility_date = "2026-06-01"
[[durable_objects.bindings]]
name = "RATE_LIMITER"
class_name = "RateLimiter"
[[migrations]]
tag = "v1"
new_sqlite_classes = ["RateLimiter"]
$ npx wrangler dev
$ npx wrangler deploy
Migrations are how Cloudflare tracks class changes over deploys: you add a new tag whenever you create, rename, or delete a class, not for ordinary code edits. Use new_sqlite_classes, not the legacy new_classes, for anything new, as the rules page recommends.
The sharp edges
Single-threaded is the feature and the ceiling. One object handles its requests one at a time, so a hot object is a throughput bottleneck. The limits page gives a soft limit of 1,000 requests per second per object, and the rules page puts realistic throughput at roughly 200-500 requests per second once each request does storage writes. Past that, shard the key across several objects and aggregate. The docs also say plainly: do not build a single global object that handles all requests.
Locality is real but not free. An object sits in one region. A user on the far side of the planet pays the round trip to reach it. Pick your naming scheme so objects sit near the traffic that uses them: per-room objects tend to cluster naturally, global singletons do not.
Awaits break write batching. Writes issued without an intervening await coalesce into one atomic transaction; awaiting each put between steps gives that up. For multi-step updates, use the synchronous KV API or transaction().
Cost shows up as requests, duration, and storage operations, and it's easy to underestimate storage when every request does a read and a write. As of October 2026, Workers Paid includes 1 million requests a month, then $0.15 per million; duration is $12.50 per million GB-s, billed on wall-clock time at 128 MB per object; SQLite rows written cost $1.00 per million after 50 million included. Batch where you can.
And don't reach for a Durable Object as a read cache. High-fanout reads of rarely changing data belong in KV or the cache, which replicate everywhere. Funneling a million reads through one single-threaded instance throws away the edge entirely.
Questions people ask
What are Cloudflare Durable Objects used for?
They coordinate state that needs a single source of truth at the edge: rate limiters, counters, chat rooms and collaborative documents, per-user sessions, game lobbies, and distributed locks. Each object is single-threaded with its own strongly consistent storage, so all requests for one name are serialized through one instance. They are a poor fit for read-heavy caching, which belongs in Workers KV.
How many requests per second can a Durable Object handle?
Cloudflare documents a soft limit of 1,000 requests per second per object. Its own guidance says simple pass-through work reaches about that, JSON parsing and validation drops it to roughly 500-750, and requests that write storage land around 200-500. When one key needs more, shard it across several objects (by suffixing the name) and aggregate the results.
Are Durable Objects available on the free plan?
Yes, as of October 2026, but only SQLite-backed Durable Objects. The Workers Free plan includes 100,000 requests and 13,000 GB-s of duration per day, plus 5 GB of stored data in total. Free-plan operations past a daily limit fail rather than bill, and the counters reset at 00:00 UTC. Workers Paid has a $5 monthly minimum and higher included usage.
The call we'd make
If you have genuine coordination (a counter, a lock, a room, a rate limit that has to be correct), Durable Objects are the cleanest answer we've used at the edge, and they replaced a Redis cluster we were tired of babysitting. If you're only caching or serving read-heavy data, stay in KV. The test we apply: does this need one thing to be the source of truth? If yes, give it an object, and plan the sharding before it gets hot. If no, keep it stateless and fast. For the algorithm choices inside the limiter itself, see our guide to API rate limiting.
Sources
Cite this article
Kiril Urbonas (2026). Cloudflare Durable Objects: Stateful Coordination at the Edge. DevOpsNess. Updated 2026-10-31. https://www.devopsness.com/blog/cloudflare-durable-objects-stateful-edge
[Cloudflare Durable Objects: Stateful Coordination at the Edge](https://www.devopsness.com/blog/cloudflare-durable-objects-stateful-edge) (Kiril Urbonas, DevOpsNess, updated 2026-10-31)
More from Cloud
Explore more articles in this category
.NET 8 Support Ends November 10: The Lambda and Azure Functions Checklist
.NET 8, .NET 9, the Lambda dotnet8 runtime and the Azure Functions in-process model all lose support on November 10, 2026. Inventory commands, the isolated-worker migration and a CI gate.
Google Cloud's europe-west2 Outage: One Zone Lost Power and the Region Stalled for 6 Hours
On October 20, 2026, europe-west2-b lost power when its generators never started. Cross-zone control-plane timeouts then degraded the whole London region. What happened and the gcloud audit to run now.
Lambda Python 3.10 Is Deprecated Today: Find Every Function and Move to 3.13
AWS deprecated the Lambda python3.10 runtime on October 31, 2026. Functions keep running, patches stop. The inventory commands, IaC diffs and AL2023 gotchas for moving to python3.13.
You might have missed
Evergreen posts worth revisiting.