风易: On the free tier, do not wait synchronously for bookkeeping and log writes; return first, then persist to the database in the background with waitUntil
On 2026-11-16, X user @Michael_liyang (风易) wrote: on the free tier, do not wait synchronously for bookkeeping and log writes; return the response first, and throw write operations to the background. A synchronous write to D1 both slows the response and burns CPU time. The approach is: the response contains only the business result; bookkeeping goes through waitUntil to persist in the background; on failure, enter the queue for a catch-up write. The chain is request → call upstream → return the result first → write the books in the background → catch-up write on failure.
- Products
- D1Workers
- Source
- Author experience𝕏 post
- Author
- 风易 (@Michael_liyang)
Key points
- This is a new background-write tutorial by this author. It is a different topic from D1 batch writes and queuing concurrent writes, so it is a separate piece.
Original sources
Published
Original post
Read on 𝕏On 2026-11-16, X user @Michael_liyang (风易) wrote: on the free tier, do not wait synchronously for bookkeeping and log writes; return the response first, and throw write operations to the background. A synchronous write to D1 both slows the response and burns CPU time. The approach is: the response contains only the business result; bookkeeping goes through waitUntil to persist in the background; on failure, enter the queue for a catch-up write. The chain is request → call upstream → return the result first → write the books in the background → catch-up write on failure.
风易 | AI 工具链
@Michael_liyang · Original 𝕏 post
先说结论:免费档里记账、写日志别同步等,响应先返,写操作扔后台。同步写 D1 既拖响应又烧 CPU 时间。做法:1 响应只放业务结果;2 写账走 waitUntil 后台落库;3 失败进队列补写。链路:请求→调上游→先返结果→后台写账→失败补写。
More to read
qianshuixia2026: D1 free row-read cap burned twice in one day, plus R2 and Workers pitfalls after the first paid orders
浅水虾 (@qianshuixia2026) published a 16 November 2026 X article after the first $12 and $29 orders. On 14 November a 10-minute cron full-table scan burned the D1 Free 5 million daily row-read cap in 2 hours 14 minutes; the same evening the author ran wrangler d1 execute --remote statistics that scanned about 4.08 million rows in 5 minutes and hit the cap again, then paid $5 to upgrade to Workers Paid. The article also covers an R2 multipart complete() customMetadata mismatch that failed a >24 MB export five times (50 credits sent as apology), 128 MB / 10 ms / 50-subrequest walls that a paid plan does not lift, and Queues’ 10,000 daily operations with three operations per delivered message.
igorrizzom: a forgotten Durable Object alarm billed US$ 2,038; Support refunded US$ 1,533.29, leaving US$ 505.
X user @igorrizzom (Igor Rizzo), who also posted on Cloudflare Community as igorarm (urnaaovivo.com), says a personal, non-commercial prototype that collected public election data in Brazil was left running after the October 25 runoff. A Durable Object kept rescheduling itself via alarm every ~5 seconds and writing to SQLite, and the invoice reached US$ 2,038, almost all from DO rows written, with about 10k pageviews. The author says budget alerts were set up but went to an old inbox that was never checked, and that alerts do not stop usage. Spend limits for Workers and Durable Objects were only announced on November 13, after almost all of the usage; the author then set a US$ 1 spend limit, turned the collector off, and removed Cron Triggers. The author says Support refunded US$ 1,533.29 as a one-time courtesy. The remaining US$ 505, which the author later described as US$ 500 of usage plus the US$ 5 Workers Paid fee, was closed as final; the author asked for a supervisor review in case #02442826 (follow-up to #02435308) and also asked @SidChatterjee whether any goodwill path remained for pre-launch cases. There is no Cloudflare staff reply on the public X thread or the Community thread. Public Support actions are reported by the author.
Lunora: codegen lints that name the billing meter a loop moves
Daniel (@_prisis_) says a Cloudflare bill spike is usually a loop, not traffic; his framework Lunora now flags count_without_index, queue_dispatch_cycle, cron_every_minute and container_long_sleep_after at codegen, before deploy, naming the meter each one moves.