How I keep Cloudflare under $5: where surprise bills come from
Ashish Sharma (@sarmaasis) runs several sites on the $5 Workers Paid plan and lists, product by product, the usage patterns he says quietly run up a Cloudflare bill, ending with a 12-item checklist.
- Products
- WorkersQueuesKVR2D1Durable ObjectsWorkers AIVectorizeBrowser RenderingStreamImages
- Source
- Author experienceDEV Community
- Author
- Ashish Sharma (@sarmaasis)
Key points
- The author says most surprise bills he has read about come from a few products doing far more work than their owners realized, and recommends turning on billing notifications and usage alerts first so a runaway loop shows up as an email.
- Workers: serve static files as static assets, cache responses that do not change per user, and rate-limit bots at the WAF before they reach Worker code. Cloudflare’s current Workers pricing page says static asset requests are free and unlimited, and that with Workers Caching a cached response is still billed per request while CPU time is billed only when the Worker runs.
- Queues, KV and R2: a Queues message usually costs three operations, batching does not lower the count and each retry adds a read; keep KV writes out of hot paths and avoid listing keys in request paths; avoid calling R2 HeadObject or ListObjects on every request and keep that metadata in D1 or KV. The current Queues pricing page confirms operations are counted per message rather than per batch and that each retry incurs a read.
- D1 and Durable Objects: D1 bills rows scanned rather than rows returned, so index the columns you filter on; Durable Object duration is billed at 128 MB per object, so let idle objects hibernate, use the WebSocket Hibernation API, and watch pending I/O and alarms. Cloudflare’s current Durable Objects pricing page says objects idle and eligible for hibernation are not billed for duration, and pending I/O can keep an object in memory for up to 15 minutes.
- Other products: cache Workers AI results and pick the smallest acceptable model, work out the Vectorize query formula with your own vector count before launch, close Browser Rendering sessions and use fetch when JavaScript rendering is not needed, delete unused Stream videos, and avoid generating Images sizes nobody uses. The author notes he has not verified Cache API billing.
Original sources
Original source · Published
Open original sourceThread opener on 𝕏: the author says his Cloudflare bill is $5 a month for several sites and that most surprise bills come from a few products doing more work than counted.
Read on 𝕏Ashish Sharma
@sarmaasis · Original 𝕏 post
My Cloudflare bill is $5/month, and I run several sites on it. Most surprise bills come from a few products doing more work than you counted. Here's where the money goes:
Thread 2/4: Workers Paid includes 10M requests and 30M CPU ms; serve static files as static assets; a Queues message costs three operations and batching does not reduce the count.
Read on 𝕏Ashish Sharma
@sarmaasis · Original 𝕏 post
2/4 Workers: $5/mo includes 10M requests and 30M CPU ms. Serve static files as static assets (free and unlimited). Queues: each message costs 3 operations (write, read, delete). 1M included, then $0.40 per million. Batching doesn't reduce the count.
Thread 3/4: do not write KV on every request; avoid R2 HeadObject or ListObjects on every request; D1 bills rows scanned, so index filtered columns.
Read on 𝕏Ashish Sharma
@sarmaasis · Original 𝕏 post
3/4 KV writes cost $5 per million after 1M included. Reads are $0.50 per million after 10M. Don't write on every request. R2: 10 GB free, storage $0.015/GB-month, egress free. Avoid HeadObject or ListObjects on every request. D1: you pay for rows scanned, so index the columns…
Thread 4/4: let idle Durable Objects hibernate, cache Workers AI results, prefer fetch over Browser Rendering, and a link to the full guide with checklist.
Read on 𝕏Ashish Sharma
@sarmaasis · Original 𝕏 post
4/4 Durable Objects: duration is billed at 128 MB per object, so let idle ones hibernate. Workers AI: 10k Neurons/day free, then $0.011 per 1k. Cache the results. Browser Rendering: 10 hours included, then $0.09/hr. Use fetch when you can. Full guide with checklist:…
More to read
Lanshu: an AI-assisted Cloudflare billing risk checklist
Lanshu (@LufzzLiz) shares a six-step prompt for checking account ownership, usage, runaway consumption and budget alerts. Replies add alarm logging, email delivery checks and separate notifications.
babynarc: a Durable Objects alarm loop and a surprise bill that grew from $300 to $500.
@babynarc says an alarm loop in an old Durable Object he thought was inactive left him badly burned: he watched a surprise $300 bill grow to $500 even after killing it. Replying to Cloudflare's Dane Knecht and Kenton Varda, he suggests prepending budget-alert details to every `cf` result by default.
hfcorriez: $100+ of AI-driven extra usage over two months, reported cancelled after emails.
@hfcorriez says AI caused over $100 of extra consumption over two months. He says that after two rounds of email explaining the situation to Cloudflare, the charges were cancelled, and posts a screenshot of two negative line items (-$31.92 and -$75.42) marked Fully Applied.