Spend management enforces billing caps, pauses costly Workers and Durable Objects, and provides alerts, near-real-time tracking.
Cloudflare has introduced Spend Management in Beta, changing developer cost control from notification to enforcement. With more than 10 million developers building on its platform, any pay-as-you-go (PayGo) customer can now set spending thresholds and have Cloudflare pause activity when a limit is reached. The first supported products are Workers and Durable Objects, and the feature can be paired with AI Gateway spend limits to manage compute and AI inference costs.
Usage notifications and budget alerts already existed for paid plans, but informing is not the same as controlling. A configured spending limit can trigger a blocking policy, pause the product automatically, and send alerts before and at the cap.
What the feature does
Spend Management is available through the dashboard, the cf command-line interface, and the REST API. In the dashboard, the path is Manage Account > Billing > Spend limits. For a supported product, a customer can define a spending limit, set a recipient email, and configure one or more alert thresholds. If notifications are enabled, Cloudflare sends alerts when evaluated spend reaches a threshold or the limit. When the limit is reached, the product is paused automatically.
The dashboard shows current billing-cycle costs in near real time, under 10 minutes. Its overview panel lists which products have thresholds and limits. In Cloudflare’s example, Workers triggered two alerts before hitting the hard limit. An audit log records who changed a limit and when, or when a cap was reached.
Billing cycles follow the subscription, not the calendar. A cycle starts when the paid subscription begins, not when a Worker is deployed or a spending cap is created. A subscription starting October 10 generally has a cycle of October 10-November 10.
To resume service, a customer can raise the limit above the current cycle’s accumulated spend, disable or delete the blocking policy, or wait until the next billing cycle when the existing block expires.
Control options at a glance
| Mechanism | What it does | Scope | Main limitation |
|---|---|---|---|
| Usage notifications and budget alerts | Inform the account owner about spend | Paid plans | Does not stop usage |
| Spend Management | Sets thresholds and can pause a product when the limit is reached | PayGo; starts with Workers and Durable Objects | Beta; limited product coverage; cost data is near real time |
| AI Gateway spend limits | Applies per-user and per-model budgets to AI requests routed through a gateway | Workers AI and other AI providers used through AI Gateway | Covers requests routed through the gateway |
The cf command-line interface includes commands such as cf billing spend-policies list, create, get, update, delete, audit list, and activity list. A sample REST API request can create a policy with name "Workers spending cap", product_id "workers", enabled true, threshold_cents 10000, action "usage_block", and notification_email "[email protected]". Documentation is available in Cloudflare’s Developer Documentation.
What gets paused
Once a cap is enforced, new invocations of that product are rejected. Cloudflare says it pauses only customer-code invocations that incur costs. In Workers, that means Cron Triggers and Queue consumer invocations are paused, while static assets continue to be served.
This distinction matters for production systems. A cap can stop scheduled or queued execution without taking static content offline, but it can still interrupt workflows that depend on those invocations.
How the system is built
The visible product is a dashboard switch, but the engineering problem is distributed. Cloudflare needs to turn an invocation anywhere on its network into a blocking decision that can be applied globally. Building Spend Management required work across multiple teams, changes to existing systems, and new systems from scratch.
The first problem is volume. Each billable invocation can produce usage measurements such as requests, CPU time, execution duration, or storage operations. Transporting every raw event to a central rating engine would not scale efficiently. Cloudflare instead uses a two-stage metering pipeline that combines events into usage aggregates.
In the first stage, parsers convert raw events into usage measurements and combine matching measurements into typically one-minute buckets. Even then, several records can still describe the same account and time window. In the second stage, a separate service merges those partial aggregates over typically five-minute windows and archives the consolidated data for later analytics and reconciliation. The result is that downstream engines process accumulated usage rather than every individual event.
The Usage Engine converts those aggregates into standardized usage records containing the account, usage window, metric, quantity, and relevant dimensions. It maps product-specific meters into supported usage metrics. Processing is partitioned by account, so each account’s usage and subscription information meet in the same place. That lets it maintain accumulated usage and apply included allowances without coordinating across pricing processors on every update. Different partitions run in parallel, while each partition keeps local state and a durable write-ahead logging changelog on disk. The design supports less cross-partition coordination, consistent pricing, parallel processing, and recoverability.
The Rating Engine is the core block: it answers how much an account has spent so far, given its consumption, subscription, and pricing. It combines usage records, subscription information, and pricing rules. Those streams arrive independently, and failures or missing webhook data can leave usage without the subscription context needed to price it. If that happens, the system retains the usage as pending and revisits it when the missing information arrives, instead of treating unpriced usage as free.
For accumulated spend, the engine uses a product catalog database that defines usage metrics, allowances, rates, and rounding rules. One million CPU milliseconds does not necessarily mean an extra charge: the engine first applies the account’s included CPU allowance, then prices any excess. It prices accumulated usage rather than rounding and charging each request independently.
After spend is calculated, policy evaluation decides whether warning or blocking thresholds are reached. Reporting shows estimated usage charges in the dashboard through APIs and can send email alerts via Cloudflare Email Service.
Enforcement is asynchronous. The Rating Engine does not sit in the request path and does not directly reject requests. A policy service sends the cap to the runtime configuration service and to Quicksilver, Cloudflare’s internal key-value store built for fast global replication and low-latency access at planet scale. The cap propagates to nodes asynchronously. During its periodic refresh, the runtime picks up the cap and starts rejecting capped invocations or operations. Because enforcement uses local state, requests do not wait on the Rating Engine.
Why this matters, and what remains uncertain
For developers, the value is hard boundaries. Cloudflare already had budget alerts, but alerts do not stop runaway spend. Spend Management can reduce the risk of unexpected bills from unplanned usage, especially for Workers and Durable Objects workloads. Pairing it with AI Gateway spend limits gives teams a way to manage both compute and AI inference costs, although the two systems apply to different layers of the stack.
There are also clear limitations. The feature is in Beta and starts with only Workers and Durable Objects. The under-10-minute billing view is near real time, not instant, and enforcement is asynchronous, so a cap may not stop every event the moment the limit is crossed. Customers should account for that gap when applying hard blocks to production systems.
The product model is also primitive-level. Today, caps apply to products such as Workers and Durable Objects. A developer may want to cap the total cost of one application—a Worker script that also uses R2 or Workers AI—without disabling the same primitives for every application. Cloudflare says that is a future direction, not the current feature.
What Cloudflare plans next
Cloudflare describes the Beta as a major milestone but the start of a roadmap. More products and primitives will join the catalog, with the internal architecture intended to make onboarding easier for product teams. The company also wants to shorten the gap between measurement and enforcement from under 10 minutes toward under a minute.
The most notable future direction is application- and agent-based budgets. Cloudflare points to AI agents as a cost-control use case: rogue agents can enter unconstrained recursive reasoning loops, generating thousands of dollars in costs through high-frequency, expensive API calls and causing denial-of-service issues on databases and other services. AI Gateway already lets developers give an agent a budget for AI requests routed through it; Spend Management’s next steps could extend similar logic to broader application costs.
Source: Cloudflare Spend Management Beta announcement and Cloudflare Developer Documentation.
Last updated: 2026-06-22
Reader notes 0
- No notes yet. Corrections and first-hand test results are welcome.
