Dev News Daily ENDE

Cloudflare Spend Management can pause Workers and Durable Objects at a spending limit

Cloudflare has introduced Spend Management in beta, letting pay-as-you-go customers set a spending limit per product and have Cloudflare pause the product when the limit is reached. The blog post announcing it says spend controls have long been among the most requested features of its developer platform, and that the existing usage notifications and budget alerts did not solve the problem because informing is not the same as controlling. The first products covered are Workers and Durable Objects.

Limits are configured in the dashboard under Manage Account, Billing, Spend limits, through the cf CLI or through the REST API. For each product a customer sets a limit, a notification email and one or more alert thresholds. When the evaluated spend crosses a threshold or the limit, Cloudflare sends an email; at the limit, a blocking policy takes effect and the product is paused. The API call shown in the post creates a policy with a threshold_cents value and an action of usage_block, and the CLI offers commands to create, list, update and delete policies and to read their audit log and activity.

The post is precise about what stops. Only customer-code invocations that incur costs are paused: in Workers, for example, Cron Triggers and Queue consumer invocations stop, but static assets continue to be served. Service resumes when the limit is raised above the cycle's accumulated spend, when the blocking policy is disabled or deleted, or when the next billing cycle starts. Cloudflare also notes that the billing cycle starts with the paid subscription, not on a calendar month, so a subscription that began on 10 October runs from the 10th to the 10th.

The dashboard shows current-cycle costs per product in near real time, which the post puts at under 10 minutes, along with an audit log of who changed a limit and when a cap was reached. The rest of the post describes the system behind it: usage is aggregated close to the source in a two-stage metering pipeline, first into roughly one-minute buckets and then into roughly five-minute windows, before a rating engine evaluates spend.

Cloudflare suggests combining Spend Management with AI Gateway's existing per-user and per-model budgets for inference costs. Other products are to follow.

Cloudflare Spend Management can pause Workers and Durable Objects at a spending limit
Cloudflare Spend Management can pause Workers and Durable Objects at a spending limit — Dev News Daily

Why it matters

A cap that blocks is a different trade-off from an alert. It protects against a runaway bill, but it turns a cost problem into an availability problem, and the evaluation lag of up to about ten minutes means spend can overshoot the cap before the block lands. Teams that enable it need to decide which products may stop in production and who gets the email.

Written by Victoria Shinder.