billflare.

风易: 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.

Products
WorkersKVD1
Source
Author experience𝕏 post
Author
风易 (@Michael_liyang)

Key points

  • This is a new free-tier scheduled-task tutorial by this author. The topic is task overlap and KV locks. It is not merged into the author's existing free-tier quota guide or D1 no-index-created guide.

Original sources

  1. Published

    Original post

    Read on 𝕏

    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.

    风易 | AI 工具链

    @Michael_liyang · Original 𝕏 post

    先说结论:免费档定时任务最怕的不是失败,是重叠。Cron 每 5 分钟触发一次,上次没跑完下次又来了,同一批数据被处理两遍。做法:执行前先拿 KV 锁,拿不到直接跳过;锁带过期时间,防任务挂了锁死;跑完写 D1 再放锁。链路:触发→拿锁→拿不到跳过→拿到执行→写结果→放锁。锁防重复,不防慢。
Author experienceWorkers +1

Pricing a runaway Cloudflare bill before hard caps ship: Workers loops vs always-awake Durable Objects

Lenny Enderle (@lenny_enderle) prices runaway scenarios from the docs: a Worker looping at 1,000 req/s for a day is about $34 plus the $5 plan, while 1,000 Durable Objects kept awake all month is about $4,050. Until hard caps ship, he lists a per-invocation CPU limit, WebSocket hibernation and your own usage counter as guards.

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 experienceWorkers +3

A personal AI agent on the free tier: what runs out first

A dev.to guide by akaranjkar08 builds a Telegram agent on Workers, Durable Objects and Workers AI and works through the free quotas: at about 30 chats a day, Workers AI neurons run out first, then Durable Object row writes, then CPU time. Cost figures are the author's examples.