Your Cloudflare Workers KV rate limiter is probably attacking itself
I ship a small Cloudflare Worker (a Claude Code status line that pays users a cut of disclosed sponsor revenue -- not the point of this post, just context for where the traffic pattern came from). Every install polls /line every 10-20 seconds while the user is coding. That's a lot of requests hitting one Worker. The setup that seemed fine Rate limiting a Worker endpoint by install ID looks like a…
Cloudflare Workers KV rate limiter can inadvertently attack itself when used at large scale. The issue arises because every install polls the same Worker every 10-20 seconds, causing a significant number of requests to hit that single endpoint. By using KV for rate limiting, the Workers KV on the free plan has a daily cap of 100,000 get() reads, not per namespace or key.
Every /line call performs a get() to check the rate limit, which quickly exhausts the daily quota. Once the quota is reached, all KV reads, including those unrelated to rate limiting, start failing with hard errors. The solution is to use the platform's edge cache for rate limiting checks, which don't count against the daily read quota.
By caching the rate limit data, the Worker can avoid KV reads for this path. Additionally, the actual install data reads should be moved to a Durable Object, one instance per install, to prevent KV from being a bottleneck. This approach ensures that hot path operations can run freely without impacting the overall system.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.