billflare.

Cloudflare Spend Guard: an account-wide usage circuit breaker via shared KV

A Worker that reads account-wide usage every minute, trips when any monitored metric reaches 95% of a configured allowance, and publishes the state to shared KV for opted-in projects to refuse billable work. The README stresses it is not a hard cap.

Products
WorkersKVD1R2
Source
Community resourceGitHub repository
Author
i-zrhe2016

Key points

  • A cron runs every minute and queries the GraphQL Analytics API from the start of the billing cycle (not a rolling 30 days): D1 rows read/written and Workers requests are required; D1 storage, R2 operations and R2 storage are optional. Default allowances are the Workers Paid and R2 included amounts, which the README says must be set to the real plan.
  • It trips when used × 100 ≥ limit × 95; the 5% margin covers the gap between detection and enforcement (minute refresh, consumers re-reading every 30 seconds). Stale state (over 900 seconds by default) also counts as tripped, and with BUDGET_REQUIRE_STATE=1 a missing state does too, which the README says production should enable.
  • R2 operations it cannot classify, including unknown new ones, are counted as Class A so the breaker trips earlier rather than later. Workers CPU, KV, Durable Objects and Queues are not monitored; an unmonitored metric nearing its allowance will not trip it.
  • The README states plainly that this is application-level circuit breaking and cannot guarantee zero overage: data has delay, a Worker returning 503 still uses requests and CPU, existing storage and callers that have not opted in keep running, and plan and fixed add-on fees are not waived. No license file is published.

Original sources

  1. Published

    Cloudflare Spend Guard: an account-wide usage circuit breaker via shared KV

    Open original source

    A Worker that reads account-wide usage every minute, trips when any monitored metric reaches 95% of a configured allowance, and publishes the state to shared KV for opted-in projects to refuse billable work. The README stresses it is not a hard cap.

Author experienceWorkers +3

Turn free allowances into daily budgets with alerts at 70% and 90%

风易 (@Michael_liyang) says 100,000 requests a day and 5 million rows read a day are hard walls, not a safety margin: split production and test into different Workers and D1 databases, alert at 70% and 90%, and degrade before the site returns 500s.

Other

stevesprompt: an agent clicked Upgrade in the Cloudflare dashboard and charged $1.5k; the money was refunded.

X user @stevesprompt (Steve Huang) says an agent clicked Upgrade in his Cloudflare dashboard and he was charged $1.5k, and that the money was luckily refunded. The author then lists precautions before an agent can spend money or send anything. The post does not name the product that was upgraded. There is no official public Cloudflare response in the thread.

Community resourceWorkers +7

Cloudflare Cost Hub: free-tier vs paid allowances, cost drivers and month-end forecasts

An MIT-licensed dashboard that signs in with Cloudflare OAuth, reads account analytics across products, colour-codes usage as free, within paid allowance or billable, ranks per-instance cost drivers, forecasts month-end cost and emails threshold and budget alerts.