01 // What it’s for
Why reach for DurabilityRouting
Use DurabilityRouting when a single Durable Object becomes a write or concurrency hotspot and you want to fan incoming work across N independent shards without introducing an external router, queue service, or global registry. Each shard stays an ordinary Durable Object with its own SQLite storage.
02 // How it works
Inside your Durable Object
- 01Zero extra infrastructure: Inside each shard,
DurabilityRoutingowns zero tables and zero alarms—it simply tracks in-flight work and 60 one-second timing buckets in isolate memory. - 02Isolate-local cache & Power-of-Two: The calling Worker caches each shard's latest
loadsnapshot in memory and picks the lighter of two candidates within the current adaptive shard width (W = 1..N). - 03Feedback on the return path: Every RPC response carries a fresh
result.loadsnapshot straight back to the caller so routing converges immediately without extra probe hops. - 04No silent failover: If a chosen shard fails or errors, the caller receives the error directly rather than silently duplicating state onto another shard.
Storage
None (in-memory buckets)
Alarm
None (0 alarms)
Import
durability/routing