State Beyond Statelessness

“Durable” is quietly becoming a key term in serverless computing. The idea: give state a home in systems that are normally built to be stateless. A typical cloud function runs, executes its code, and forgets everything. No memory of prior invocations, no retained context — a clean slate every time. Durable primitives change that model by letting you spin up something closer to an object instance that persists and can be addressed again later.

Cloudflare's Durable Objects

Cloudflare’s Durable Objects implement this directly. They are, in essence, class instances with three defining traits:

  • Objects: A Durable Object is an instance of a class written in JavaScript (or another supported language). The class defines its public interface via methods; an instance combines that code with private state.
  • Unique: Each object carries a globally-unique identifier and lives in exactly one location worldwide at any given moment. Any Worker that knows the ID, regardless of where it runs, can send messages to that single, specific object.
  • Durable: Unlike ordinary JavaScript objects, these can persist state to disk. State is private to each object, so storage access is fast, and the object can hold a consistent in-memory copy and operate on it with zero latency. When idle, the in-memory instance shuts down; it is recreated on demand later.

The real-time possibilities here are significant.

Azure's Durable Functions and Entities

Microsoft Azure uses the same “durable” vocabulary in Durable Functions, part of which includes Entity Functions. The documentation frames entities as:

Entities behave a bit like tiny services that communicate via messages. Each entity has a unique identity and an internal state (if it exists). Like services or objects, entities perform operations when prompted to do so. When an operation executes, it might update the internal state of the entity. It might also call external services and wait for a response. Entities communicate with other entities, orchestrations, and clients by using messages that are implicitly sent via reliable queues.

Azure's docs lean toward readers who work with such systems daily, but the core concept lines up closely with Cloudflare's approach. Entities are addressable by identity, persist their state, and readily support shared, real-time scenarios — for instance, showing a video game's live score to every connected client.