Running a job board on Workers Free: error 1102, D1’s 50 queries per request, and shared egress IPs
SagaSu (@sujingshen) describes keeping DMtheFounder on the Workers Free plan: SSR CPU of P50 54 ms against a 10 ms limit caused error 1102 until he edge-cached anonymous pages, an admin job hit D1’s 50-queries-per-invocation limit until he batched writes, and IndexNow 429s came from shared Workers egress IPs.
- Products
- WorkersD1WAF
- Source
- Author experience𝕏 article
- Author
- SagaSu (@sujingshen)
Key points
- Wall 1: error 1102 (Worker exceeded resource limits). He reports CPU time per request of P50 54 ms, P90 206 ms and P99 437 ms for React SSR against the Free plan’s roughly 10 ms. Fix: for requests without a session cookie or Authorization header, check caches.default first and cache the rendered page for 5 minutes, keyed by the URL without utm_* parameters plus the deployment version ID from the version_metadata binding; a cache hit costs about 1 ms of CPU. He also renders 60 roles instead of all and memoizes per-category counts per isolate for 5 minutes. He says he does not yet have post-change CPU numbers.
- Wall 2: D1 allows 50 queries per Worker invocation on Free (1,000 on Paid). An admin button that ran up to eight UPDATEs per job failed past about six jobs. Fix: one SELECT, decide in JavaScript, write only empty columns through db.batch() in chunks of 50. Related trap: one D1 statement can bind at most 100 parameters.
- Wall 3: IndexNow returned 429 because Workers outbound requests share IP addresses with many other sites; he moved the push to a VPS cron that submits only new, changed or removed URLs.
- Bonus: a WAF custom rule (the Free plan includes five) blocks scanner paths such as /wp-admin/install.php before they run the Worker. He plans to pay $5 a month once signed-in traffic, which cannot be cached, grows.
Original sources
Published
Original post
Read on 𝕏SagaSu (@sujingshen) describes keeping DMtheFounder on the Workers Free plan: SSR CPU of P50 54 ms against a 10 ms limit caused error 1102 until he edge-cached anonymous pages, an admin job hit D1’s 50-queries-per-invocation limit until he batched writes, and IndexNow 429s came from shared Workers egress IPs.
SagaSu
@sujingshen · Original 𝕏 post
https://t.co/CktVG1TS8Q
Read originalArchived
SagaSu · @sujingshen
This archive does not contain the complete text.
Running a job board on Cloudflare Workers' free plan: what broke and how I fixed it
I run DMtheFounder, a job board for early engineering roles that startup founders post themselves on X and Hacker News. It's a one-person project, so I built it on the Cloudflare Workers free plan: TanStack Start for the app, D1 (SQLite) for data, and Workers for everything else. Global, fast, and $0 a month. That worked until it didn't. Here are the three walls I hit, in order, and what got me past each one. Wall 1: Error 1102, or "10ms is not a lot of CPU" One evening I was replying to people on X with links to the site, and a few clicks later the site started showing Error 1102: Worker exceeded resource limits. The free plan gives each request about 10ms of CPU time. The metrics page told the story: CPU time per request was P50 54ms, P90 206ms, P99 437ms. Server-rendering a React page with a few hundred job cards and some counts simply doesn't fit in 10ms. Most requests got through on burst allowance; under a small spike, they didn't. Upgrading to the $5 paid plan would have fixed it in a minute. I wanted to see how far I could get first. Fix 1: cache whole pages at the edge for signed-out visitors. This was the big one. Almost everyone on a job board is anonymous, and they all see the same page. So in the Worker's fetch handler: If the request has no session cookie and no Authorization header, look it up in caches.default first. On a miss, render as usual, then store a copy for 5 minutes. The cache key is the URL with tracking parameters (utm_*) stripped and the rest sorted, plus the current deployment's version ID, so every deploy starts with a clean cache. Signed-in users and admin pages never touch the cache. The version ID comes from the version_metadata binding in wrangler.jsonc. A cache hit costs about a millisecond of CPU instead of fifty. Fix 2: render and query less. The home page used to render every live role. Now it renders 60 with a "Show more" link (?n=120). The per-category counts used by the landing pages are memoized per isolate for five minutes instead of being recomputed on every request. What about the CPU numbers after both changes? Honestly, I don't have them yet. These changes went out recently, and there isn't a full week of post-change metrics to quote. I'd rather not publish a number I can't back up, so I'll update this post with the new P50 and P90 once the data is in. Wall 2: D1 allows 50 queries per request A week later an admin button ("fill empty fields from research") started failing. The SQL was fine. The problem was the count: it ran up to eight small UPDATEs per job, one after another, and the free plan allows 50 D1 queries per Worker invocation (1,000 on paid). Past about six jobs, it died. The fix is the one the D1 docs recommend: read once, decide in JavaScript, write in batches. One SELECT pulls every listing and its current values; only the columns that are actually empty get an UPDATE; the updates go out through db.batch() in chunks of 50. A few hundred jobs now cost a handful of queries. Related trap: a single D1 statement can bind at most 100 parameters. An inArray() over 150 IDs fails. Chunk it, or do the matching in JS. Wall 3: IndexNow kept returning 429 I wanted Bing to pick up new roles quickly, so the site pinged IndexNow whenever a job went live. Every request came back 429 Too Many Requests. IndexNow rate-limits by source IP, and Workers' outbound requests leave from IP addresses shared with a huge number of other sites. My few pings a day were sharing a bucket with everyone else's. I already had a small VPS running the daily data pipeline, so the push moved there: a cron job reads the sitemap, compares it with what it sent last time, and submits only new, changed, or removed URLs. First run: 447 URLs, HTTP 200. The same script pattern now also notifies Google's Indexing API for job pages. Lesson: when something rate-limits by IP, the Workers egress IP is not really yours. Bonus: let the edge drop junk traffic for free Workers metrics also showed a steady trickle of GET /wp-admin/install.php and friends. The site isn't WordPress, but each of those requests still ran the Worker and rendered a 404. One WAF custom rule (the free plan includes five) blocks them before they reach the Worker: Action: Block. Zero CPU for scanners. Where this leaves me The site still runs on the free plan. What made the difference, roughly in order of impact: Edge-cache anonymous pages, keyed by deployment version. Batch D1 writes; read once, write only what changed. Don't render what nobody scrolls to. Move anything IP-sensitive off Workers. Block junk at the edge. I'll upgrade the day signed-in traffic grows, because those requests can't be cached. At $5 a month that's an easy call. But it was worth learning where the limits are first. If you're an engineer who'd rather message a founder than fill in an application form, the roles are at dmthefounder.com. Founders can post for free. Happy to answer questions about the setup in the comments. — Sagasu, building DMtheFounder
These source blocks are preserved as an appendix without changing the article text.
Appendix 1 · typescript
```typescript const cacheKey = isEdgeCacheable(request) ? edgeCacheKey(request, env.CF_VERSION_METADATA.id) : null; if (cacheKey) { const hit = await caches.default.match(cacheKey); if (hit) return hit; // ~1ms instead of ~50ms } const response = await render(request); if (cacheKey && isStorable(response)) { ctx.waitUntil(caches.default.put(cacheKey, forEdge(response.clone()))); } ```Appendix 2 · plaintext
```plaintext (http.request.uri.path contains "/wp-") or (ends_with(http.request.uri.path, ".php")) or (starts_with(http.request.uri.path, "/.env")) or (starts_with(http.request.uri.path, "/.git")) ```Chinese version of the same X article ("用 Cloudflare Workers 免费套餐跑一个招聘站:撞了三堵墙,以及怎么绕过去的"), posted the same minute.
Read on 𝕏SagaSu
@sujingshen · Original 𝕏 post
https://t.co/0kkj53QNZZ
Read originalArchived
SagaSu · @sujingshen
This archive does not contain the complete text.
用 Cloudflare Workers 免费套餐跑一个招聘站:撞了三堵墙,以及怎么绕过去的
我在做 DMtheFounder,一个早期创业公司工程岗的招聘站,岗位都是创始人自己在 X 和 Hacker News 上发的。因为是一个人的项目,我把它整个放在 Cloudflare Workers 免费套餐上:应用用 TanStack Start,数据用 D1(SQLite),其余都跑在 Workers 上。全球都快,每月 0 元。 一直挺顺,直到撞墙。下面按顺序讲三堵墙,以及各自怎么过去的。 第一堵墙:1102 错误,10ms CPU 真的不多 有天晚上我在 X 上回复别人、顺手贴了网站链接,点进来的人一多,网站开始报 Error 1102: Worker exceeded resource limits。 免费套餐每次请求只有大约 10ms 的 CPU 时间。看指标就明白了:每次请求的 CPU 时间 P50 54ms、P90 206ms、P99 437ms。服务端渲染一个有几百张岗位卡片、还要算一堆计数的 React 页面,10ms 根本不够。平时靠突发额度扛过去,稍微来一波流量就扛不住了。 升级到每月 5 美元的付费套餐,一分钟就能解决。但我想先看看不花钱能走多远。 解法一:给没登录的访客做整页边缘缓存。 这是最大的一刀。招聘站绝大多数访客都没登录,看到的页面也一样。所以在 Worker 的 fetch 入口里: 请求里没有登录 cookie、也没有 Authorization 头时,先查 caches.default。 没命中就正常渲染,然后存一份,缓存 5 分钟。 缓存的 key 是去掉 utm_* 追踪参数、剩下参数排好序的网址,再加上当前部署的版本号。每次发布新版本,旧缓存自动作废。 登录用户和后台页面完全不走缓存。 版本号来自 wrangler.jsonc 里的 version_metadata 绑定。命中缓存时 CPU 大约 1ms,原来要 50ms 左右。 解法二:少渲染、少查询。 首页原来一次渲染全部在招岗位,现在先渲染 60 个,底部放一个「Show more」链接(?n=120)。各个专题页要用的分类计数,在每个 isolate 里缓存 5 分钟,不再每次请求都重算。 两项改完以后 CPU 降到多少?老实说,现在还没有数字。这些改动上线不久,还攒不够一整周的数据,我不想贴一个站不住的数。等数据够了,我再回来补上新的 P50 和 P90。 第二堵墙:D1 每次请求最多 50 次查询 一周后,后台一个按钮(「用调研补全空字段」)开始报错。SQL 本身没问题,问题出在次数:它对每个岗位一条一条地执行最多 8 个小的 UPDATE,而免费套餐每次 Worker 调用最多 50 次 D1 查询(付费是 1000 次)。岗位超过六七个就挂了。 解决办法就是 D1 文档推荐的:读一次,在 JS 里判断,批量写。一条 SELECT 读出所有岗位和当前值,只对真正空着的字段生成 UPDATE,再用 db.batch() 每 50 条一批发出去。现在几百个岗位也只占几次查询。 相关的坑:D1 单条语句最多绑定 100 个参数。对 150 个 ID 做 inArray() 会直接报错。要么分批,要么在 JS 里匹配。 第三堵墙:IndexNow 一直返回 429 我想让 Bing 尽快收录新岗位,所以每上架一个岗位,网站就通知一次 IndexNow。结果每次都返回 429 Too Many Requests。 IndexNow 按来源 IP 限流,而 Workers 发出去的请求,用的是和海量其他网站共享的出口 IP。我一天几次的通知,和别人的请求挤在同一个额度里。 我本来就有一台小 VPS 在跑每天的数据流程,于是把推送挪了过去:定时任务读站点地图,和上次推过的清单比较,只推新增、改动和下架的网址。第一次跑:447 个网址,HTTP 200。后来同样的写法也用来通知 Google 的 Indexing API。 教训:凡是按 IP 限流的服务,Workers 的出口 IP 都不算是你自己的。 附加:让边缘免费挡掉垃圾流量 Workers 的指标里还有一串稳定的 GET /wp-admin/install.php 之类的请求。我的网站不是 WordPress,但这些请求照样会运行 Worker、渲染一个 404 页面,白白花 CPU。 一条 WAF 自定义规则(免费套餐有 5 条)就能在它们进 Worker 之前挡掉: 操作选「阻止」。扫描器从此不花一点 CPU。 现在的状态 网站仍然跑在免费套餐上。按效果大小排,真正起作用的是: 匿名访问的整页边缘缓存,按部署版本区分。 D1 批量写入:读一次,只写变了的。 没人会滚动到的内容,就不要渲染。 对 IP 敏感的事情,挪到 Workers 之外去做。 垃圾请求在边缘挡掉。 等登录用户多起来我就升级,因为登录用户的请求没法缓存,每月 5 美元很好决定。但先搞清楚限制在哪里,是值得的。 如果你是工程师,比起填申请表更想直接私信创始人,岗位都在 dmthefounder.com。创始人免费发布岗位。关于这套架构有任何问题,欢迎留言。
These source blocks are preserved as an appendix without changing the article text.
Appendix 1 · typescript
```typescript const cacheKey = isEdgeCacheable(request) ? edgeCacheKey(request, env.CF_VERSION_METADATA.id) : null; if (cacheKey) { const hit = await caches.default.match(cacheKey); if (hit) return hit; // ~1ms instead of ~50ms } const response = await render(request); if (cacheKey && isStorable(response)) { ctx.waitUntil(caches.default.put(cacheKey, forEdge(response.clone()))); } ```Appendix 2 · plaintext
```plaintext (http.request.uri.path contains "/wp-") or (ends_with(http.request.uri.path, ".php")) or (starts_with(http.request.uri.path, "/.env")) or (starts_with(http.request.uri.path, "/.git")) ```
More to read
Spend Management: spending limits and alerts for Workers and Durable Objects
Cloudflare’s 13 November 2026 open beta lets pay-as-you-go accounts set a monthly USD spending limit on Workers or Durable Objects usage charges (after included usage). The limit can block new billable work or send email only. It is not a guaranteed invoice cap, is account-wide per product, and does not cover the Workers Paid subscription fee, stored Durable Object data, or other products such as KV, R2 and Workers AI.
stevesprompt: an agent clicked Upgrade in the Cloudflare dashboard and charged $1.5k; the money was refunded.
X user @stevesprompt (Steve Huang) says an agent clicked Upgrade in his Cloudflare dashboard and he was charged $1.5k, and that the money was luckily refunded. The author then lists precautions before an agent can spend money or send anything. The post does not name the product that was upgraded. There is no official public Cloudflare response in the thread.
风易: the easy leak on a free R2 public bucket is the public URL, not the quota itself
风易 (@Michael_liyang) argues that a public R2 bucket’s direct URL can be hotlinked by anyone, so other sites’ traffic is billed to the bucket owner. The recommended three steps are a custom domain instead of a bare r2.dev link, a Worker Referer allowlist that returns 403 otherwise, and signed expiring URLs for images.