/ Field note

Cloudflare state and storage, simply

How Workers KV, Durable Objects, in-memory state, and Durable Object storage fit together.

Tall hand-drawn explainer comparing Cloudflare KV, Durable Objects, memory, and durable storage.

Cloudflare offers several places to put state, but they make different guarantees. The image reduces the choice to an access-pattern question: does the application need globally distributed reads, or one authoritative coordinator?

KV distributes reads

Workers KV is a global key-value store. Copies of a value can be read close to users around the world, which makes KV a strong fit for feature flags, configuration, and read-heavy caches. Distribution also means a recent write may not be visible everywhere immediately.

Choose KV when reads happen in many regions, data changes relatively infrequently, and slight staleness is acceptable.

A Durable Object coordinates state

A Durable Object is a single stateful coordinator addressed by an object ID. Requests for the same ID are routed to the same authority, so the object can order operations and protect invariants. This is useful for a chat room, game session, inventory item, booking resource, or any shared state that needs one correct answer.

The object's memory is fast but temporary. It can disappear when the object restarts or is evicted, so live connections and derived counters may live in memory while messages, scores, and settings go into persistent storage.

Durable storage survives restarts

Durable Object storage is the private persistent database attached to an object. It survives restarts and supports transactional updates. Pairing it with a Durable Object gives an application ordered execution plus durable records.

The rule of thumb shown in the image is intentionally simple:

  • Use KV for global, read-heavy data where cached or slightly stale values are acceptable.
  • Use a Durable Object with durable storage for an authoritative state machine where ordering and consistency matter.

Persistence alone should not decide the architecture. Start with who reads the data, who writes it, and whether concurrent operations must agree immediately.