billflare.

Cloudflare billing pitfalls thread

The author organizes Cloudflare billing risks by product and shares experience with budget alert emails.

Products
WorkersD1Durable ObjectsEmail SendingContainers
Source
Author experience𝕏
Author
yvonuk (@mcwangcn)

Key points

  • The author covers D1, Durable Objects, Workers, Email Sending, and Containers in five numbered posts.
  • The thread links billing risks to full-table writes, request and CPU usage, bot-triggered email, and separate container charges.
  • Later posts add the author’s experience with delayed budget-alert emails and replies saying Workers Paid bills overages while Workers Free stops service. Replies from other users are labeled with their authors. All collected nodes and their original text appear below.

Original sources

  1. Original post

    Read on 𝕏

    The author organizes Cloudflare billing risks by product and shares experience with budget alert emails.

    yvonuk

    @mcwangcn · Original 𝕏 post

    这个帖子今天得到很多关注,看得出大家对Cloudflare的账单计费很感兴趣,我就再写个串推说说Cloudflare比较容易爆账单的几个点,都是我自己交学费换来的血泪教训,可能并不全面,欢迎大家补充🧵 https://t.co/MrerzXCOJR
  2. D1: the author warns that full-table UPDATE statements grow write volume as tables expand, especially when linked to requests.

    Read on 𝕏

    yvonuk

    @mcwangcn · Original 𝕏 post

    1. Cloudflare D1 D1绝对称得上是CF账单杀手,我自己就被搞过上千刀。最大的坑是写入费用(每百万行1美元),如果你在workers里不注意sql用法,随便update all,当表格变大之后这个费用是很惊人的,尤其当数据库update与网络请求连在一起时更是分分钟爆单 pic.twitter.com/FvVKrYlnLf
  3. Durable Objects: the author highlights database and request usage as separate billing concerns.

    Read on 𝕏

    yvonuk

    @mcwangcn · Original 𝕏 post

    2. Cloudflare Durable Objects Durable Objects是另一个容易爆的点,因为它既有D1数据库的计费,又有Requests的计费,还能无限scale。好在DO本身也有点复杂,会去真正用它的地方也不多。
  4. Workers: the author separates request charges from CPU-time charges and describes experience with CPU costs.

    Read on 𝕏

    yvonuk

    @mcwangcn · Original 𝕏 post

    3. Workers Cloudflare Workers计费分两块:Requests和CPU time,这两部分都有可能爆单。比如@keking99最近的1000刀账单就主要来自海量Requests,而我自己之前则是被CPU time搞过。
  5. Workers CPU time (author's follow-up to post 3): usage beyond 30 million ms costs $0.02 per million ms, about $0.072 per hour; a buggy request can hold several to tens of seconds of CPU, which adds up across thousands of requests, and the author says this can be capped with limits: cpu_ms in Wrangler config.

    Read on 𝕏

    yvonuk

    @mcwangcn · Original 𝕏 post

    Workers CPU time计费超出30million ms的部分是每million ms $0.02,也就是$0.072/小时。单个请求的Workers CPU time通常不超过几百ms,但如果程序有问题,单个request占用几秒至几十秒也很常见,叠加到几千次request就已经不是个小数字了。不过好在这一项可以通过Wangler配置的limits: cpu_ms来限制
  6. Email Sending: the author describes bot sign-ups amplifying email usage on a magic-link login flow.

    Read on 𝕏

    yvonuk

    @mcwangcn · Original 𝕏 post

    4. Email Cloudflare的Email Sending服务,好用且价格不贵,每月超过3000封的部分每1000封0.35美元。我个人比较喜欢用Email magic link作为登录方式,但也因此很容易被人滥用,比如我做的https://t.co/5OtLSlDoF8经常短时间内被几千个bot注册,光是Email费用就好几刀一天,不过这也是比较容易解决的。
  7. Containers: the author explains that container charges are separate from the Workers Paid subscription and reports idle costs from a personal test.

    Read on 𝕏

    yvonuk

    @mcwangcn · Original 𝕏 post

    5. Containers(完) Cloudflare的Containers也是很容易爆账单的服务,年初CF做了个在Containers里运行openclaw的demo,不少推友以为只需要$5/月的worker paid费用,其实还有Containers费用,我亲自测试每月啥都不干也需要30美元左右。Containers相当于CF的VPS,但比一般的VPS要贵多了,不建议使用。
  8. The author replies to @shmily7 and quotes this thread, saying Durable Objects are a big pitfall and easy to get wrong.

    Read on 𝕏

    yvonuk

    @mcwangcn · Original 𝕏 post

    昨天刚写到Cloudflare账单几个坑点,今天就刷到你这条。Durable Objects确实是个大坑,用不好很容易出bug。https://t.co/DPMweBHbqT
  9. Budget alerts: the author reports emails arriving hours or a day after unexpected usage.

    Read on 𝕏

    yvonuk

    @mcwangcn · Original 𝕏 post

    关于Cloudflare的账单问题,再多说两句: 有网友说不想爆单可以在Cloudflare上设一个预警(Alert),超额就会收到Email提醒。 这没错,但是依旧有个漏洞:Cloudflare Alert发送都是有延迟的,我之前被爆单的Alert常常是晚了几小时或一天。 https://t.co/ip3t7fgHE6 pic.twitter.com/3un1SwuL9w
  10. Budget alerts (author's self-reply): for runaway bills caused by bugs or external attacks, a delay of several hours is fatal; the alert usually arrives too late.

    Read on 𝕏

    yvonuk

    @mcwangcn · Original 𝕏 post

    对于程序bug或外部攻击导致的爆单,几小时的延迟是致命的,通常收到Alert的时候已经晚了
  11. Reply from another user, jodie0404 (@gogogif): asks whether Workers and D1 overages are not billed, saying they used R2 and have stopped.

    Read on 𝕏

    jodie0404

    @gogogif · Original 𝕏 post

    Works 和d1超出不会有账单吧,我用了r2,现在不用了
  12. The author answers @gogogif: on Workers Paid any overage is billed; on Workers Free overage only stops the service.

    Read on 𝕏

    yvonuk

    @mcwangcn · Original 𝕏 post

    Workers Paid不管哪项只要超额就有帐单。Workers Free没事,超额只会停服。
  13. Reply from another user, cs (@gggg_eth): asks whether one can monitor the bill and stop the service via the API.

    Read on 𝕏

    cs

    @gggg_eth · Original 𝕏 post

    不能自己监控账单,使用api停止服务吗?
  14. The author answers @gggg_eth: no, because usage figures are displayed with a delay.

    Read on 𝕏

    yvonuk

    @mcwangcn · Original 𝕏 post

    不行,用量显示是有延迟的
  15. Reply from another user, qianyi1001 (@yuqianyi1001): says post-paid serverless budgets cannot really be controlled, and suggests multiple quota alerts at 50%, 70%, 80% and 90%, taking action such as rate limiting or raising the budget at 80%.

    Read on 𝕏

    qianyi1001

    @yuqianyi1001 · Original 𝕏 post

    这种 serverless 的后付费的都有这个“弊病”,budget control 压根 control 不了。只能多设一些监控,比如 50% quota,70%,80%,90% - 达到 80% 的 quota 的时候,就必须采取 actions 了,考虑流控或增加预算了。
  16. Replying to a $500 D1 bill thread, the author says he received a $1,300 Cloudflare bill for D1 writes a couple of months earlier.

    Read on 𝕏

    yvonuk

    @mcwangcn · Original 𝕏 post

    @Cyberlane @Cloudflare I was in the same boat a couple of months ago. Got a $1300 Cloudflare bill for D1 writes. https://t.co/itOl3Cr9Hj
  17. The author quote-posts the same thread, calling it another D1 bill like his, both caused by large volumes of writes, and links his earlier write-up.

    Read on 𝕏

    yvonuk

    @mcwangcn · Original 𝕏 post

    又一个被Cloudflare D1账单背刺的例子,和我之前收到的巨额账单很像,都是大量写入造成的,我在这里有写👉https://t.co/trR5sxNMeK https://t.co/b7wX78pHCQ
  18. The author explains that his bill came from updating all rows in a table on certain Worker requests; as the table grew and bots hit the site, writes exploded. He says it was mainly his own fault and he paid the bill.

    Read on 𝕏

    yvonuk

    @mcwangcn · Original 𝕏 post

    @Cyberlane @Cloudflare Mine was due to table updates. I carelessly updated all rows in a table for certain workers requests. When the table grows and I got attacked by massive bots, the write operation exploded. Because it was mainly my own fault, I paid the bill in the end without much compaint.
Author experienceWorkers +4

Cloudflare costs $5 a month, but the bill is not capped

不追高 (@Ariella1213) writes an X article explaining that Workers Paid’s $5 is a minimum, that per-product limits and budget alerts do not cap the account bill, and how denial-of-wallet requests, write amplification, delayed stops and background retries add cost.

D1

hiromsaeden: an unindexed D1 query loop billed $2,129.00; a $953.74 courtesy credit left $645.38 due.

Cloudflare Community user hiromsaeden, in a post-mortem of a personal hobby project on Workers and D1, says an unindexed GROUP BY aggregate query scanned about 877,000 rows to return 30 rows, and an unintended loop triggered about 315,000 runs across two billing cycles. In the Oct 15 – Nov 15 cycle alone, 1,447,580,203,670 rows (1.44 trillion rows) were read, on top of the previous cycle’s usage. The author says the October invoice IN-83890481 was $529.88 USD, paid in full out of pocket; the November invoice IN-89082487 was $1,599.12 USD ($1,447.58 D1 Rows Read + $6.16 Workers CPU + $145.38 tax); and the total billed was $2,129.00 USD against an expected budget of about $20/month. After noticing the issue on Nov 2–3, the author deleted the Worker and the D1 database; Support confirmed all reads had stopped. In case #02408621, Support offered a $275.00 courtesy credit for October and advised holding it until the November invoice was issued on Nov 15. In case #02434399, Support applied a one-time courtesy credit of $953.74 (which included the held $275.00), leaving a final balance of $645.38 USD, and said the review was complete and no further adjustments can be made. The author, having already paid $529.88, says the remaining $645.38 cannot be afforded and the account will be downgraded on Nov 22. The author also says a budget alert fired once at the $37 mark but did not stop the charges, and that D1 currently has no hard spending cap. There is no Cloudflare staff reply on the public thread; the Support actions are reported by the author.

Author experienceD1 +2

Michael Liyang: record every AI call in D1 and downgrade before the budget runs out

@Michael_liyang argues that on a free tier the danger is not one expensive call but not knowing which call is expensive: write each call's usage to D1 by user and model, have a daily Cron check budgets and downgrade first, and look at which user is burning quota rather than only the total.