Durable Objects bill shock: the alarm loop and how to not fund it
A widely shared post-mortem put a Durable Object alarm loop at $34k in eight days with zero users. The pattern is boring and preventable: know which meters run when nobody is there, hibernate by default, and cap spend before you learn the price list.
The three meters that actually bill you
Requests: 1M/mo included, then $0.15/M (WebSocket messages count 20:1 for billing).
Duration: 400k GB-s/mo included, then $12.50/M GB-s. You pay wall-clock while the object is active or idle-but-not-hibernatable — a connected socket you accepted() without the Hibernation API bills duration for the whole connection.
Storage: SQLite-backed DOs have billed rows since 7 Jan 2026 (writes 50M/mo included, then $1/M; stored $0.20/GB-month) — the meter many older cost tables forget.
Cloudflare's own example (the 7× lever)
Same workload, two outcomes (Cloudflare DO pricing docs, Nov 2026): 100 objects × 100 connections, ~1 message/min each — $142.95/mo without hibernation vs $20.65/mo with the WebSocket Hibernation API. Requests are identical; duration is the whole difference. FluxyChat rooms hibernate when idle for exactly this reason.
The alarm-loop failure shape
setAlarm reschedules itself unconditionally → each alarm is a billed row write + request, forever, even at zero users.
Pending I/O keeps an object in memory up to 15 minutes per operation — a forgotten fetch can hold duration open.
No spend limit set: Cloudflare supports per-dimension spend caps (requests, duration, storage ops) with pause behavior — but stored-data charges continue during a pause, so caps are a seatbelt, not a cure.
How FluxyChat rooms are shaped
WebSocket hibernation when a room is quiet: the next message wakes the object with state intact — no idle duration bill (see the cost table on /compare).
Plan quotas enforced Worker-side (persisted messages, agent invokes, webhooks) stop a runaway tenant before it becomes a Cloudflare invoice surprise.
Agent runs persist partial output throttled to D1 (agent_runs.partial_content) and resume on the next invoke — an interrupted stream is a billing non-event too: no duplicated generation loops.
Self-host on your account: set the native DO spending limit as your outer guardrail (docs: Durable Objects spend management).
Pre-flight checklist (any DO chat)
Hibernation API on every socket; never accept() without a hibernation plan.
Alarms: exponential backoff + terminal condition + max iterations. Test with zero users for 24h and read the bill.
Spend limit set on requests + duration before first real traffic.
Storage budget: estimate rows written per message (history + indexes), not just gigabytes.
One dashboard glance weekly: requests vs duration vs rows — duration is where chat surprises live.
Production next step
FluxyChat packages the same stack: RoomDurableObject, D1 history, multi-tenant JWT, reconnect-aware SDK, and operator console. MIT self-host or hosted beta.