A Cloudflare Worker that accepts /api/send and /api/batch in the common open-source page-analytics payload shape and serves the /s.js page tag (no cookies, no storage, honours Do Not Track). - Site keys checked against SITES KV entries (cached 60 s). - Bots, tools, link previews and prefetches: 202 and dropped. - Visitor id = HMAC(daily salt, site, ip, user agent), 128 bits; the IP is used in memory only and never stored or forwarded; fails closed without VISITOR_SALT_SECRET. - One Durable Object per org: monthly per-site caps (over the cap: 202 with x-railyard-capped: 1, counted, not stored; paused orgs get x-railyard-paused: 1), 2 s buffered flush in one ingest request per org, retry on failure, and a per-minute insights_events usage event to Rago ($0 shadow). - contract/INGEST-API.md and ingest-batch.schema.json: the ingest API RYP-D2 implements, the SITES entry the console writes (RYP-E1), and the Rago event. Tests run the Worker in Miniflare (workerd): batching, visitor hash built from a real client IP with no IP downstream or in persisted DO/KV files, bot and prefetch drops, unknown sites, caps with Rago counts, paused sites, fail-closed. A simulated-clock test drives 1,000 events a second for 60 s through the collector. The workerd load run answered all 60,000 events 202 with at most one downstream request per site per second, but only at 126 events a second on this overloaded Mac (load average about 72); LOAD-RESULT.md records that the 1,000/s rate needs a re-run on an idle machine. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1.2 KiB
1.2 KiB
Insights edge load test
Run by node test/load.mjs 60 1000.
{
"date": "2026-09-29T13:29:49.249Z",
"runtime": "Miniflare 5 (workerd 1.20260923.1), local Mac, other lanes' builds running",
"target": "1000 events/s for 60 s over 5 sites in 3 orgs",
"sent": 60000,
"elapsed_s": 475.4,
"achieved_rate": 126,
"late_seconds": 60,
"statuses": {
"202": 60000
},
"all_202": true,
"downstream_requests": 590,
"events_forwarded": 60000,
"max_downstream_requests_per_site_per_second": 1,
"raw_ip_downstream": false
}
Read this before quoting the numbers. All 60,000 events were answered 202, all
were forwarded exactly once, no site saw more than one downstream request in any
1-second window, and no IP reached a downstream body. The 1,000 events a second
rate was not reached on this machine: the Mac's load average was about 72
(other lanes were building), and a do-nothing request to the same local runtime
peaked at 195 requests a second, so the driver ran at 126 a second and took 475 s.
The rate target needs a re-run on an idle machine or with wrangler dev on a
quiet box (owner or verifier step). The 60-second, 1,000-a-second path is also
covered by test/collector-sim.test.mjs on a simulated clock.