Optimize costs
Cloudflare lists ways to find and reduce usage-based charges by product.
- Products
- Account-wide usage-based productsWorkersDurable ObjectsR2
- Source
- Official docsCloudflare Docs
Key points
- The page starts from the billable usage dashboard to find which products drive costs. General strategies are budget alerts, a weekly dashboard review, and understanding how charges accrue across a request.
- For Workers and Durable Objects, it lists Workers Logs instead of Logpush for log retention, and the WebSocket Hibernation API for idle connections, since duration billing pauses while the object hibernates. For R2, it lists lifecycle rules to Infrequent Access, batching, presigned URLs instead of proxying through Workers, and Cache-Control headers so cached objects skip R2 reads.
- Budget alerts use one account-wide dollar threshold; per-product usage notifications for bytes, requests, or minutes are configured separately in Notifications.
Original sources
Undated
Optimize costs
Open original sourceCloudflare lists ways to find and reduce usage-based charges by product.
More to read
Feng Yi: CORS preflight can also burn the free allowance; uncached OPTIONS add one extra Worker invocation before every real request
On 2026-11-13, X user @Michael_liyang (Feng Yi) wrote that cross-origin preflight also burns the free allowance. The browser sends an OPTIONS preflight before each cross-origin request; if it is not cached, that is one extra Worker invocation before every real request, and under volume this is what hits the wall first. The author’s approach: add Max-Age on the preflight response to lengthen the cache, allow only fixed origins and methods, and do not use wildcards. The path is request → preflight cache lookup → return on hit → enter the Worker only on a miss.
Kun Save Point (@Savepoint_kk): a D1 bug rewrote unchanged data into a $2,739.12 bill; $2,141 goodwill credit granted.
Kun Save Point (@Savepoint_kk), an indie developer who says he recently lost his job, says a bug repeatedly rewrote unchanged data while inefficient queries amplified reads, producing a $2,739.12 Cloudflare bill already paid via PayPal (D1 rows written $2,641.00, rows read $64.06, other services $34.06); he says his bills were usually under $10 a month. Cloudflare granted a $2,141 goodwill account credit under case #02391058. He asks for it to be converted into a refund to the original PayPal payment, or at least for relief on the $2,641 write charges, and later writes that the initial request was declined and has been reopened for additional review. On October 25 he adds that he missed the only alert email Cloudflare sent, whose amount was not particularly high, and received no further warning before the large card charge; on October 26 he writes that the refund request to the original payment method is still under further review. On November 10 he posts a timeline saying that after following up on November 10–11, support again stated the $2,141 could only remain as account credit and the remaining $598.12 was still undecided while the ticket was being closed.
风易: On the free tier, what Cron fears most is task overlap; use a KV lock to skip rather than running again in parallel
On 2026-11-13, X user @Michael_liyang (风易) wrote an experience note about scheduled tasks on the Workers free tier: what is feared most is not failure, but overlap. Cron triggers once every 5 minutes; if the previous run has not finished, the next one arrives, and the same batch of data is processed twice. The approach the author gives is: take a KV lock before executing, and skip immediately if it cannot be obtained; the lock must carry an expiration time, so that a hung task does not leave the lock stuck; after the run finishes, write to D1 and then release the lock. The chain is trigger → take the lock → skip if not obtained → execute if obtained → write the result → release the lock. The author emphasizes: the lock prevents duplicates; it does not prevent slowness.