Skip to content
Auto
English

Operations

Everything here is per workspace, read over HTTP with a claim (admins and owners, unless a route says otherwise) or from the client. None of it returns row values from personal fields, and the metrics carry counts, sizes and durations only.

Route
GET /status, GET /health the Worker answers; no claim
GET /engine/workspaces/<id>/status the workspace’s status, with durability: { seq, flushedSeq, snapshotSeq, lastFlushError }. Every write at or below flushedSeq is in R2. Any claim for the workspace may read it

/status?after=<seq> waits until a transaction lands past seq, or 25 seconds: a cheap way for a script to wait for a write without a socket.

GET /engine/workspaces/<id>/metrics answers how hard a workspace is being worked and whether it is healthy. It starts with health: { status, reasons }, where status is ok, degraded or failing:

Reason Status When
recovering degraded a restore from R2 is running; requests answer 503 workspace_recovering
recovery_failing failing a restore is running and R2 refuses it
flush_failing failing the last flush to R2 failed; writes past flushedSeq exist only in the Durable Object
flush_lagging degraded the oldest write not yet in R2 is over 5 minutes old, or over 10,000 writes wait. Under 30 seconds is normal
snapshot_overdue degraded the next snapshot is more than a day late
webhooks_dead_lettered degraded at least one webhook event is dead-lettered
write_latency_high degraded transaction p95 over 1 s, from at least 20 samples
live_updates_slow degraded live update p95 over 2.5 s, from at least 20 samples

health is computed only from the numbers in the rest of the answer, so you can check it.

metrics are counters and latency histograms from the Durable Object’s memory: transactions committed, refused, conflicting and deduplicated; reads and named SQL queries served and refused; sockets, live queries and their updates; presence and broadcast traffic; flushes, snapshots and restores; and, with shards, stock.* and sockets.relayed. They cover one object’s lifetime, not the workspace’s history: an idle object is evicted and starts again from zero, which every answer says with restartsCounters: true, since and uptimeMs. Timers (query, transaction, sql, subscriptionUpdate, flush, snapshot, recovery) give exact count, sumMs, maxMs and meanMs; p50Ms, p95Ms and p99Ms are estimates from fixed buckets, published in latency.bucketsMs.

gauges are read from SQLite when you ask, so they are exact and survive a restart: sockets, live queries, presence targets, topics, storageBytes, the log’s size, webhook counts, and durability: seq, flushedSeq, pendingSeq, lastFlushAt, lastFlushAgeMs, flushAttempts, nextAttemptAt, lastFlushError, oldestPendingAt, and the snapshot’s snapshotSeq, snapshotAgeMs and snapshotDueAt. measurement labels every figure measured or estimated.

Reading it. A healthy workspace has pendingSeq falling back toward zero between alarms, no lastFlushError, subscriptions tracking the clients you expect, and a steady transaction p99. Durability is falling behind when pendingSeq grows across several reads or lastFlushAgeMs keeps rising; flushAttempts above zero with a lastFlushError means R2 is refusing and the flush is backing off. With several shards, /metrics answers for one: add ?shard=<name>.

Which reads cost a workspace the most, and why:

const profile = await db.$queryProfile({ sort: "rowsRead", limit: 20 });
await db.$queryProfile({ reset: true });

or GET /engine/workspaces/<id>/queries (DELETE clears it). Every read statement the engine runs is recorded under its SQL text: typed reads (query), live queries (live) and named SQL queries (sql). For each it keeps the runs, the rows returned, the rows SQLite read (the figure Cloudflare bills reads by) and the time, and the costliest come back with SQLite’s own plan. fullScans names the model tables a plan reads whole; indexCandidates names the columns it compares on them, the candidates for .index(). Values are always bound, so no filter value or subject is ever recorded.

Reading it. A statement high in rowsRead with a full scan reads whole tables: if its indexCandidates name a column you filter by, add .index() to that field and run tapedb migrate dev. A high rowsRead without a full scan returns many rows; page it. A live statement runs again on every write to its models, so a scan there costs more than its count suggests. On Cloudflare the clock only moves at I/O, so rank by rowsRead, not time. The record lives in memory, holds the 200 costliest statements and starts again with the object.

GET /engine/workspaces/<id>/log?before=&limit=&model= reads the transaction log, newest first: each entry’s seq, time, writer (with audit: true), rows per model and operation, and up to 100 ops. Values are shown only for models whose read rule is a role the caller meets, never for personal fields. next is the cursor for the following page. The log reaches back as far as the retention keeps it.

A single row’s history, with writers and times, is db.$history. The Studio shows both.

Three routes for the day a consumer breaks. They need an admin, since a retry sends data to a third party.

const report = await db.$webhooks(); // GET /webhooks
const dead = await db.$webhookDeliveries({ status: "dead" }); // GET /webhooks/deliveries
await db.$webhookRetry({ status: "dead", endpoint: 0 }); // POST /webhooks/retry

The report lists each endpoint’s pending, delivered and dead counts, oldestPendingAgeMs, whether it is backingOff, and head: the one delivery it waits on. Events go in seq order and nothing overtakes a failing one, so head’s attempts, lastStatus, lastError and nextAttemptAt explain a stalled endpoint on their own. policy shows the retry schedule in force. An endpoint the deployment has since removed is reported with retired: true, so a count that never falls is explained.

Deliveries lists the bookkeeping per event, newest first, filtered by status, endpoint and before. It says what each event was about (model, op, seq, eventId), never its body.

Retry makes deliveries due now, named by ids or by filter (oldest first, at most 500 a call; more: true says to call again). It re-sends the original event, with the same eventId, seq and signed body, and restarts its attempt count and age. A revived event keeps its place in order, so that endpoint’s newer events wait behind it again. A delivered event is never sent again, even when named. Nothing here touches a committed write.

tapedb export, backup, restore, erase, move and shards cover the rest; see CLI.