Cloudflare has launched Spend Management in beta, a way to stop an app from running up an unexpected bill. You set a spending limit, and Cloudflare pauses billable activity when you reach it.
Any pay-as-you-go account can use it. It covers Workers and Durable Objects for now, with more products planned. Workers is Cloudflare’s service for running your app’s code. Durable Objects is its storage-backed service for apps that keep state, such as a chat room or a counter.
What stops, and what keeps running
When a limit is reached, Cloudflare pauses only the invocations of your code that cost money. For Workers, that means Cron Triggers (scheduled jobs) and Queue consumer invocations (background jobs that process queued work) stop. Static assets keep being served.
You can set one or more alert thresholds below the limit, plus a recipient email for notifications. Limits can be managed in the dashboard under Billing > Spend limits, with the cf command-line tool, or through the REST API.
The cap is not instant
Cloudflare enforces limits asynchronously. Costs show up in the dashboard within about 10 minutes, and the cap then takes time to spread across Cloudflare’s network. Usage can continue to accrue charges after you cross the line.
Set the limit below the most you can afford to pay, and send the alert email to someone who will see it. A runaway loop in a scheduled job is the kind of problem this is meant to contain, but it will not stop the first few minutes of it.
Cloudflare plans to shorten the gap between measurement and enforcement to under a minute, cover more products, and add budgets for a single application or agent. Its AI Gateway already has separate per-user and per-model budgets for AI requests that pass through it, which you can use alongside the new limits.
End of article