Skip to content

Cloudflare lets you cap Workers and Durable Objects spending

New spend limits in the dashboard and the cf CLI can block usage once a billing threshold is hit, or just email you first.

Source: Cloudflare

Cloudflare added spending limits for Workers and Durable Objects on 13 November, letting you set a cost threshold for the current billing period instead of finding out about an overage on the invoice. You configure them under Billing > Spend limits in the dashboard, or with the cf CLI’s billing spend-policies create command.

Each policy picks one of two actions: an email alert that warns you without touching traffic, or a hard limit that blocks the product’s operations once spend crosses the threshold. Cloudflare warns that usage reporting and blocking both take time, so recorded spend can run past the limit before it actually kicks in. To resume service you raise the limit, turn it off, or wait for the next billing period.

cf billing spend-policies create \
  --name 'Workers $50 cap' \
  --product-id workers \
  --threshold-cents 5000 \
  --action usage_block

Why it matters: a runaway Worker or a Durable Object stuck in a retry loop can rack up a bill before anyone notices. A hard spend cap is a blunt instrument, it will take your app down once it fires, but for side projects and non-critical services that is often the trade you want against an open-ended invoice.

Share

Related reading

More from The Wire

All briefs