Cloudflare Durable Objects for Beginners

Build coordinated stateful applications with Cloudflare Durable Objects, from stable identities and SQLite persistence to alarms, concurrency and real-time WebSockets.

Cloudflare

Introduction

Build counters, rooms and reservations that keep a consistent shared state. Durable Objects give each named entity a stable coordination point, serialized execution and its own SQLite-backed storage.

The course contains seven guided labs and one independent reservation-repair challenge. You move from named objects and persisted activity to concurrency, alarms and WebSocket behavior.

What You Will Learn

  • Route stable names to independent objects
  • Persist and retrieve room activity
  • Coordinate concurrent reservations without overbooking
  • Schedule expiry with object alarms
  • Broadcast room updates over WebSockets
  • Restore connection context after object reconstruction
  • Diagnose a cross-room identity leak
  • Repair an overbooked workshop while preserving valid bookings and totals

Who This Course Is For

Workers developers who want to coordinate stateful applications and live clients.

Prerequisites: Complete Workers foundations, Connect LabEx to Your Cloudflare Account and the basic SQL keys, constraints and queries introduced in D1 D01–D02.

Learning environment: Each lab starts in a fresh LabEx VM using your own independently authorized account. You create uniquely named Workers and SQLite-backed object namespaces, then inspect runtime and Dashboard evidence. Bounded synthetic exercises use Workers Free and count toward shared allowances; no purchased domain is required.

Frequently Asked Questions

How is a Durable Object different from an ordinary Worker?

A Worker can route a request, while one named object owns the coordination point and persistent state for an entity such as a room. Names and routing therefore affect isolation.

Will I test concurrent behavior?

Yes. The reservation labs check capacity and durable totals under concurrent requests. Correctness depends on the invariant, not which request happens to arrive first.

Does a disconnected WebSocket mean its state is lost?

The course distinguishes a client connection from object-owned state and restores connection context after reconstruction. You inspect the resulting behavior rather than assuming what an idle period proves.

How do I finish an exercise?

Delete only your disposable Workers and related namespaces, confirm removal while authorized and log out. Preserve unrelated applications and account resources.

Teacher

labby
Labby
Labby is the LabEx teacher.