Cloudflare Introduces Spend Management for Workers and Durable Objects
Cloudflare has announced Spend Management in Beta, allowing pay-as-you-go customers to set spending limits and alerts for Workers and Durable Objects [1, 2].
2 min read
What Is New
Cloudflare has announced the introduction of Spend Management in Beta [1]. This new feature is available to any pay-as-you-go (PayGo) customer and currently applies to Workers and Durable Objects [1]. The company plans to bring these controls to more products in the future [1, 2].
Spend Management allows developers to set specific spending thresholds and choose whether Cloudflare should pause activity when those limits are reached [1]. This is intended to prevent unexpected bills caused by unplanned usage [1]. Users can also set up email notifications to receive alerts at specific thresholds [1].
For those using AI, these controls can be used alongside AI Gateway spend limits. AI Gateway already supports budgets for Workers AI and other AI providers, which are applied to requests routed through the gateway [1]. These AI Gateway limits can be set on a per-user or per-model basis [1].
How to Use It
Users can manage these settings through the Cloudflare dashboard, the cf CLI, or the REST API [1].
To use the dashboard:
- Navigate to Manage Account > Billing > Spend limits [1].
- Enable the specific products you wish to control [1].
- Define a spending limit, a recipient email for notifications, and one or more alert thresholds [1].
- You can view current billing cycle costs in near real-time, with updates appearing in under 10 minutes [1].
To use the cf CLI:
- Install the cf CLI and select your account [2].
- Run a command such as
cf billing spend-policies create --name 'Workers $50 spending limit' --product-id workers --enabled true --threshold-cents 5000 --action usage_blockto set a $50 limit [2]. Note that the amount is entered in US cents, so 5000 equals $50 [2]. For Durable Objects, use the--product-id durable_objectsflag [2].
Limits and Privacy
There are several technical and operational limits to consider:
- The billing cycle is determined by when the paid subscription began, not by the date a Worker is deployed or a cap is created [1]. For example, a subscription starting October 10 generally runs from October 10 to November 10 [1].
- When a spending limit is reached and a blocking policy is enforced, Cloudflare pauses customer-code invocations that incur costs [1]. In the case of Workers, Cron Triggers and Queue consumer invocations are paused, but static assets continue to be served [1].
- Because usage reporting and blocking take time, recorded spend may occasionally exceed the set limit [2].
- To resume service after a limit is hit, a user must either raise the limit above the current spend, turn the limit off, or remove it [2]. Usage also resumes automatically when the next billing period starts [2].
- The dashboard includes an audit log that shows who changed a limit and when, or when a cap was reached [1].
About the author
Ali Raza, Founder
Sources
- Introducing Spend Management: Spending limits and alerts for Cloudflare — The Cloudflare Blog Official source
- Set spending limits for Workers and Durable Objects ยท Changelog — developers.cloudflare.com Official source
Drafted with AI assistance from the reports above and checked automatically for sourcing. Always confirm dates, fees and requirements on the official website before acting. Report an error · How we correct mistakes
Questions or something to add?
Ask below. We read every comment and reply when we can.