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>
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.
What
The proxy now batches live-globe posts per isolate instead of posting once per public read.
{colo, products: {"account/product": count}}message topublic-log-stream. Counts are exact; nothing is sampled.live-globe batch not delivered). It is not a WARN, so a failing globe never counts toward the WARN alerts.Why
Before this change the proxy sent about 370 posts/second at peak to one global Durable Object (about 213M requests in a week):
Expected effect, and why 3 s
Modelled monthly cost of the live globe (Durable Object requests plus CPU), against about $150 today:
The model takes the per-datacenter request rates from the last 7 days (254 datacenters; PDX alone is about a third and the top four about 60%), scales them to the 353 posts/second the Durable Object serves today, and lets each isolate post once per window plus the wait for its next request. The unbatched baseline lands at $152 against about $146 billed. The isolate count per datacenter is a guess, which is why the range is wide, and CPU is assumed to fall in proportion to posts. The window also delays activity: with the hub spreading each batch over a matching window (#289), end-to-end delay is about twice the window, and the frontend fades dots over 10 s, so 5 s is the most I would use.
WINDOW_MSinsrc/location_batch.rsand the hub'sSPREAD_SLOTSshould be changed together.How it works
src/location_batch.rsholds the pure rule and is covered bytests/location_batch.rs.src/location.rskeeps the batch in athread_local!. The request that opens a batch becomes its leader: it sleeps 3 s inwait_until(the limit is 30 s) and posts the whole batch once. A batch older than 6 s is taken over by the next request, so an evicted leader cannot strand it.Rollout
needs: deploy-public-log-streaminproduction.ymlandstaging.yml)./, so avoid that order; roll back the proxy first, or both together.Not checked
public-log-stream. It depends on how many isolates serve each datacenter. After deploying, compareworkersInvocationsAdaptive(scriptpublic-log-stream) anddurableObjectsInvocationsAdaptiveGroups(the LocationHub namespace) for the same weekday and hour before and after.LiveGlobe.tsx(source.cooporigin/main) ignores unknown fields, never readsrequestsPerWindow, and fades dots over 10 s, so no frontend change should be needed.Follow-up (separate PR): spread each batch across ticks at the hub and replay the last few seconds to new viewers.
🤖 Generated with Claude Code