Repository navigation
Conversation
The proxy posted one event per public read to a single global Durable Object (~370 req/s at peak): about $145/month of Durable Object requests and CPU, plus overload exceptions in the busiest hours. An isolate runs in one datacenter, so each isolate now gathers its public reads for 3 s and posts one batch of exact per-product counts. A busy datacenter collapses into few posts; a quiet one still reports its first request. The hub adds the counts as posted, so the tick payload is unchanged. Only the colo and product counts leave the proxy now (no coordinates, city, country or key), and the hub still accepts the old one-request-per-post form for rollout. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A failed or rejected post dropped its whole batch without a trace. Say so at info level (not WARN, so a failing globe never counts toward the WARN alerts); a Durable Object past its request limit now shows up in the logs. Also list location_batch.rs in ADR-008 and note the up-to-3-second delay. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The hub emitted each proxy batch in a single tick, so a datacenter's dots arrived as a burst every few seconds, and a new viewer saw nothing until the next live tick. Batches are now spread over the next six 500 ms ticks (conserving counts, with a rotating cursor for the remainders), keyed by absolute tick so a late alarm catches up. The idle tick is sent only once nothing is queued. A viewer who connects gets one replay message (type "tick" with replay: true) of the last three seconds already emitted, so it never overlaps the live ticks. The alarm runs only while someone watches or activity is queued, so an idle hub still stops. Batches are capped at 100 product keys without losing the datacenter's count. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This was referenced Nov 20, 2026
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #288 (proxy batching): until that merges, this diff also shows its two commits. Review the last commit,
feat(log-stream): spread batches over ticks and replay recent activity.What
The hub now smooths what viewers see, and new viewers see something immediately.
replay: trueandwindowMs, and it never includes a tick the viewer will also receive live.Why
After #288 the hub receives a lump of activity from each proxy isolate every few seconds. Without this, a datacenter's dot refreshes in bursts, and a new viewer sees an empty globe until the next live tick.
Design notes
type: "tick"with an extra field, not a new message type.LiveGlobe.tsxon source.cooporigin/mainhandles onlytype === "tick", ignores unknown fields, never readsrequestsPerWindoworviewers, and sizes dots bylog10(1 + n), so a replay of about six ticks of counts draws as one slightly larger dot. A separate type would be ignored and the replay would do nothing. The frontend needs no change.src/aggregate.mjs(spread, merge, due, replay window, prune, pending) with Node tests;location-hub.tsonly wires it to the alarm and the WebSocket.Tested
node --test: 18 tests (conservation for every count 0–50 and every cursor, round-robin remainders, key cap, late-alarm catch-up, replay window excludes unemitted and too-old ticks, pruning bounds memory, no zero counts), plustsc --noEmit.wrangler devand a WebSocket client: 12 requests for one datacenter came out as 2 per tick over exactly 6 ticks, with a single request on one tick, on 500 ms boundaries; no idle tick appeared mid-trickle and one followed once it drained. A second viewer connecting after three ticks received a replay of exactly those three (7 requests) and then the remaining three live, with no overlap and no loss. An old-style bare event still arrived, delayed to a later tick.Not checked
webSocketClosecallsws.close(code, reason), which throws "Uncaught Error" locally when a client closes without a status code. It is the same line onmain.🤖 Generated with Claude Code