惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
The GitHub Blog
The GitHub Blog
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
Google DeepMind News
Google DeepMind News
aimingoo的专栏
aimingoo的专栏
Recent Announcements
Recent Announcements
A
About on SuperTechFans
U
Unit 42
MyScale Blog
MyScale Blog
J
Java Code Geeks
博客园_首页
Blog — PlanetScale
Blog — PlanetScale
D
Docker
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 司徒正美
量子位
月光博客
月光博客
G
Google Developers Blog
V
V2EX
博客园 - 聂微东
宝玉的分享
宝玉的分享
IT之家
IT之家
Vercel News
Vercel News

ServerlessHorrors | Blog

ServerlessHorrors | $8,846.78 ServerlessHorrors | $46,485.99 ServerlessHorrors | $4,241.69 ServerlessHorrors | ~$1189.420/month ServerlessHorrors | $100,000.420 ServerlessHorrors | $738.420 ServerlessHorrors | $70,000.69 ServerlessHorrors | $22.639,69 ServerlessHorrors | $250/month ServerlessHorrors | $1273.69 ServerlessHorrors | $530.19 ServerlessHorrors | $383.69 ServerlessHorrors | $400.69 ServerlessHorrors | $103.26 ServerlessHorrors | $96,280.69 ServerlessHorrors | $120,000.420 ServerlessHorrors | $1,300.69 ServerlessHorrors | $11,000.69 ServerlessHorrors | $104,500.123 ServerlessHorrors | $23,000.420 ServerlessHorrors | $3,000.69 ServerlessHorrors | $620.123 ServerlessHorrors | $72,000.999
ServerlessHorrors | $36,000
2026-05-02 · via ServerlessHorrors | Blog

Original post

Conclusion: Fixes deployed. Bill sent to Cloudflare support with full explanation. Unknown if Cloudflare will credit it.


tldr: RetainDB (memory layer for AI agents on Cloudflare Workers + KV + Durable Objects + Queues) with 81 users racked up $36k in one month — 3.13B KV writes ($15,635), 16.62B KV reads ($8,306), 4.01B DO storage rows written ($3,962), 574M KV list ops ($2,870) — caused by three compounding bugs: an infinite queue loop passing write_mode: "async" back into itself, 12 unbatched DO storage.put() calls per memory write, and a kv.list() scan running on 95% of auth requests because legacy keys missed the hash/prefix indexes.


The three bugs:

Bug #1 — Infinite queue loop ($15k): Ingest worker forwarded the original write_mode to its internal API call. async got re-queued every time. Fix: force write_mode: "sync" on internal calls.

Bug #2 — 4B DO writes ($4k): 12 unbatched storage.put() calls per memory write across pending overlay, job state, and acks. Fix: removed all DO writes from ingest worker. Pending overlay TTL handles expiry. Dropped 12 → 2.

Bug #3 — KV list scan on every request ($2.8k): Auth fallback ran kv.list() when hash/prefix lookups missed. Legacy keys missed both indexes — 574M list ops. Fix: LEGACY_API_KEY_SCAN_ENABLED = "false".

Lessons:

  • Never pass user-facing write modes through to internal queue workers. Queue consumer IS the async handler.
  • Durable Object storage.put() is not cheap at scale. Batch everything. Use TTLs instead of explicit deletes.
  • Any fallback that touches kv.list() runs on every request in practice. KV list is $5/million.
  • Set up Cloudflare spending alerts before you need them. There’s no hard spending cap on Workers.