WquGuru: a read-only Cloudflare billing audit prompt
WquGuru (@wquguru) shares a read-only audit prompt that checks account usage, D1 query plans, loops and retries, Durable Object wake-ups, high-priced operations and Worker config, then ranks risks by worst-month cost.
- Products
- WorkersD1KVR2QueuesDurable ObjectsWorkers AIImages
- Source
- Author experience𝕏
- Author
- WquGuru (@wquguru)
Key points
- The author says D1 and serverless used the wrong way can easily produce huge bills, and asks the AI to act as a billing auditor that stays read-only: no code changes, no deploys and no writes to any resource; fixes are listed for the user to confirm.
- Account usage: run wrangler whoami and list Workers, D1, KV, R2, Queues and Durable Objects; for each D1 database run wrangler d1 info and wrangler d1 insights over 7 days sorted by reads and by writes, take the top 10 SQL statements and work out average rows scanned per execution; pull 30 days of daily D1 rows read/written, Workers requests and CPU time from the GraphQL Analytics API and match spikes to deploys.
- Code checks: indexes on WHERE/JOIN/ORDER BY columns verified with EXPLAIN QUERY PLAN (any SCAN counts), per-request count(*)/count(DISTINCT), OFFSET pagination, row-by-row INSERT/UPDATE in loops, UPDATE/DELETE without WHERE, and too many indexes on write-heavy tables (each written index adds a row written).
- Loops and retries: cron, Queue consumers sending to their own queue, max_retries, Durable Object alarms that re-arm themselves, Workers calling each other, frontend setInterval polling and scripts or agents calling APIs in loops. Durable Objects: WebSockets not using the Hibernation API, or setInterval inside a DO, keeping it awake and billing duration.
- High-priced operations and config: KV used as a counter, rate limiter or high-frequency session store; frequent R2 list; Workers AI, Images transformation parameters and public GET endpoints without rate limiting or bot checks; whether limits.cpu_ms is set and whether observability head_sampling_rate is 1.
- Output: one table of risk, file:line or SQL, billing unit, current monthly usage, worst-month cost if abused or looped, and fix, sorted by worst cost. Unit prices must come from each product's official pricing page, with unverifiable ones marked as unverified. It ends by reminding the user to set a budget alert in Billing and noting that it only sends email and does not stop services.
- Official docs (rechecked 2026-10-20): budget alerts send email when account-wide usage-based spend crosses the threshold and do not pause or cap usage; on Workers Paid, D1 indexes add a written row when writes include the indexed column.
Original sources
Published
Original post
Read on 𝕏WquGuru (@wquguru) shares a read-only audit prompt that checks account usage, D1 query plans, loops and retries, Durable Object wake-ups, high-priced operations and Worker config, then ranks risks by worst-month cost.
WquGuru
@wquguru · Original 𝕏 post
Cloudflare D1 和 Serverless,使用姿势不对还是挺容易产生天价账单的,吃过亏的朋友应该不在少数。推荐用Cloudflare的朋友都自检一下,提示词如下: 你是 Cloudflare 计费审计员。全程只读:不改代码、不部署、不对任何资源执行写操作,需要改的地方列出来等我确认。 一、账号用量(wrangler 已登录) 1. wrangler whoami,列出账号下的 Workers、D1、KV、R2、Queues、Durable Objects。 2. 每个 D1 库:wrangler d1 info <库名>;wrangler d1 insights <库名> --timePeriod=7d 分别按 reads 和 writes 排序,取前 10 条 SQL,算每次执行平均扫描多少行。 3. 用 GraphQL Analytics API 拉最近 30 天按天的 D1 rows read / rows written、Workers 请求数和 CPU 时间,标出突增的日期,对照当天的部署或代码改动。 二、代码(扫当前仓库和 wrangler 配置) 1. D1 / SQLite:WHERE、JOIN、ORDER BY 用到的字段有没有索引(用 EXPLAIN QUERY PLAN 验证,出现 SCAN 就算);每个请求都跑的 count(*) / count(DISTINCT) 统计;OFFSET 分页;循环里逐条 INSERT / UPDATE;缺 WHERE 的 UPDATE / DELETE;写多读少的表上索引太多(每个被写到的索引多记 1 行写入)。 2. 循环与重试:cron、Queue consumer 往自己的队列发消息、max_retries、DO alarm 自己重设、Worker 互相调用、前端 setInterval 轮询、脚本或 agent 在循环里调接口。 3. Durable Objects:WebSocket 没用 Hibernation API、DO 里开着 setInterval,导致一直醒着计时长。 4. 高价操作:KV 当计数器 / 限流器 / session 高频写;R2 高频 list;Workers AI、Images 变换参数、公开 GET 接口没有限流或人机验证。 5. 配置:limits.cpu_ms 有没有设;observability 的 head_sampling_rate 是不是 1。 三、输出 一张表:风险点 | 文件:行号或 SQL | 计费单位 | 当前月用量 | 被刷或写出循环时最坏一个月的费用 | 修法。 按最坏费用从高到低排。单价以 https://t.co/Usb1HgL2gw 各产品的 pricing 页为准,查不到的写「未核实」,不要编。 最后提醒我去 Billing 设 budget alert,并说明它只发邮件、不会停服务。
The author quote-posts his prompt, calling huge bills the flip side of Cloudflare's generosity; he says developers using weaker models are more likely to write loop bugs or miss edge cases, and links a case library.
Read on 𝕏WquGuru
@wquguru · Original 𝕏 post
赛博菩萨Cloudflare的B面:天价账单。 开发者特别是使用弱模型的朋友值得关注下,比较容易写出循环漏洞或者未考虑的边缘case,导致天价账单。 案例库:https://t.co/pxaeT2aRjW https://t.co/deJlFqZdXL https://t.co/9PnrVmBQgL
More to read
PennyBar: a macOS menu bar for Cloudflare and other usage-billed services
An open-source macOS menu bar app that shows this billing period's spend across Cloudflare, Vercel, Railway, Neon and PlanetScale, with total and per-account budgets.
itsabhisheksood: a Cloudflare 3D Secure prompt asked to confirm a $275.68 monthly payment.
X user @itsabhisheksood (Abhishek Sood) posted a screenshot of a Cloudflare 3D Secure prompt asking to confirm a $275.68 payment, with the caption “A vibe coding mishap or something big in the making?” The prompt describes a monthly payment. X user @thisnaeem replied calling it a $275.68 monthly Cloudflare bill and asking whether an agent provisioned something or usage compounded. The product and cause are not stated. The public outcome is unknown.
Feng Yi: On the free tier, the cheapest rollback is not a release—it's a switch in KV
On 2026-11-21, X user @Michael_liyang (Feng Yi) wrote: on the free tier, the cheapest rollback is not a release—it's a switch in KV. Steps: 1 put the switch in KV; 2 read the switch first on the request—on takes the new path, off takes the old path; 3 canary-split by user hash, 10% first and then full rollout; 4 if something goes wrong, change KV and roll back immediately, without waiting for a release. Path: request → read switch → split → new/old path → log to D1. Switches also need expiry cleanup; don't let them pile up into dead config.