diff --git a/doc/2026-11-24T02-42-57Z_research_cloudflare/2026-11-24T02-42-57Z_research_cloudflare.md b/doc/2026-11-24T02-42-57Z_research_cloudflare/2026-11-24T02-42-57Z_research_cloudflare.md new file mode 100644 index 000000000..97a57971b --- /dev/null +++ b/doc/2026-11-24T02-42-57Z_research_cloudflare/2026-11-24T02-42-57Z_research_cloudflare.md @@ -0,0 +1,33 @@ +# Cloudflare research — Workers, costs, containers and prototypes + +The Cloudflare research set from `hatch-personal/workspace/cloudflare/`: the 2026-10-20 research series (workers-paid, free-tiers, paid-only, declarative-infra, multiple-plans-tos, containers-do-costs, do-practices) at the top level plus the byte-identical `docs/` copies, the `docs/ideas.md` parked-ideas note (2026-10-26), the Cloudflare project README, the magic-environment design move-note, and the two prototype READMEs (`cf-container-hello`, `lab-ops-hub`). + +## Provenance + +Migrated 2026-11-24 from hatch-personal (`workspace/cloudflare/`) under the DOCS-MIGRATION programme (#13877). Source Markdown files are copied byte-for-byte, preserving relative paths. This is a dated research record — it states what was present at migration time and is not rewritten later. Tracking issue: #13877. + +## Contents + +- `README.md` — Cloudflare project home (Workers Paid $5 + R2 base; research set and Lab Ops Hub pointers). +- `design-magic-environment.md` — move-note (2026-10-25): v1 design reviewed and rewritten as v2 at the Atlas project home. +- `research-containers-do-costs.md` — containers vs Durable Objects cost research. +- `research-declarative-infra.md` — declarative infrastructure research. +- `research-do-practices.md` — Durable Objects practices research. +- `research-free-tiers.md` — free-tier research. +- `research-multiple-plans-tos.md` — multiple-plans / ToS research. +- `research-paid-only.md` — paid-only features research. +- `research-workers-paid.md` — Workers Paid plan research. +- `docs/ideas.md` — parked future ideas (2026-10-26, none approved or scheduled). +- `docs/research-containers-do-costs.md` — byte-identical copy of the top-level file. +- `docs/research-declarative-infra.md` — byte-identical copy of the top-level file. +- `docs/research-do-practices.md` — byte-identical copy of the top-level file. +- `docs/research-free-tiers.md` — byte-identical copy of the top-level file. +- `docs/research-multiple-plans-tos.md` — byte-identical copy of the top-level file. +- `docs/research-paid-only.md` — byte-identical copy of the top-level file. +- `docs/research-workers-paid.md` — byte-identical copy of the top-level file. +- `cf-container-hello/README.md` — known-good container reference (official hello-world image, `/`, `/lite`, `/probe`, `/worker-marker` routes). +- `lab-ops-hub/README.md` — Lab Ops Hub full-stack demo (Workers + D1/R2/KV/Queues/DO/Containers/AI/Cron/Assets, $0-overage design). + +The migrated source set contains 19 Markdown files. Including this front page, the record has 20 files. + +Code remains in place: the `cf-container-hello` and `lab-ops-hub` code, configs and assets (src/, image/, container/, public/, test/, wrangler.jsonc, package.json, tsconfig.json, Dockerfiles, schema.sql, Nix files) stay in `hatch-personal/workspace/cloudflare/` — only the two README.md files migrate here as research-prototype documentation. diff --git a/doc/2026-11-24T02-42-57Z_research_cloudflare/README.md b/doc/2026-11-24T02-42-57Z_research_cloudflare/README.md new file mode 100644 index 000000000..33b4756a0 --- /dev/null +++ b/doc/2026-11-24T02-42-57Z_research_cloudflare/README.md @@ -0,0 +1,16 @@ +# Cloudflare project (private) + +Home for Cloudflare work for Drew (account: Developing.today LLC — +Workers Paid $5 + R2 $0 base). The service meta chat is the "Cloudflare" +side chat in Muse; anything important there also surfaces in main chat. + +- docs/ — the 2026-10-20 research set (workers-paid, free-tiers, + paid-only, declarative-infra, multiple-plans-tos, containers-do-costs, + do-practices). Originally written to ~/workspace/cloudflare/ in the + hatch repo, where workspace/* is gitignored — copied here 2026-10-25 + so they are committed and pushed. +- The Atlas/magic-environment design doc lives with the Atlas project: + workspace/turso-atlas/docs/design-magic-environment.md. +- Lab Ops Hub (the demo project) is canonical in developing-today/code + at pkgs/lab-ops-hub (PR #436); the ~/workspace/cloudflare/lab-ops-hub + copy is scratch. diff --git a/doc/2026-11-24T02-42-57Z_research_cloudflare/cf-container-hello/README.md b/doc/2026-11-24T02-42-57Z_research_cloudflare/cf-container-hello/README.md new file mode 100644 index 000000000..1b3bbe428 --- /dev/null +++ b/doc/2026-11-24T02-42-57Z_research_cloudflare/cf-container-hello/README.md @@ -0,0 +1,23 @@ +# cf-container-hello — known-good container reference + +Clean-room test Worker built 2026-10-25 to debug the Lab Ops Hub +container start failures. It runs Cloudflare's OFFICIAL hello-world +container image (github.com/cloudflare/hello-world-container-image; +Docker Hub `cloudflare/hello-world`, linux/amd64 manifest copied +byte-for-byte into our account registry as `hello-world:v1`). + +Routes: + +- `/` — singleton HelloContainer (official image, default instance type) +- `/lite` — HelloLite (official image, instance_type "lite") +- `/probe` — CrawlerProbe: the Lab Ops Hub crawler image inside a fresh + container application (the isolation probe that split "our image" from + "their platform" from "the wedged Oct-20 application") +- `/worker-marker` — plain Worker response, to tell Worker-served from + container-served apart + +Findings (full story in pkgs/lab-ops-hub README, "Containers: FIXED"): +the platform and the `lite` type were fine; the Nix v3 image shape +(relative Cmd, no PATH, no shell) and the Oct-20-created container +application were both broken. `image/` holds the fixed-shape (v4) +crawler image recipe used for the probe. diff --git a/doc/2026-11-24T02-42-57Z_research_cloudflare/design-magic-environment.md b/doc/2026-11-24T02-42-57Z_research_cloudflare/design-magic-environment.md new file mode 100644 index 000000000..c5f65bd47 --- /dev/null +++ b/doc/2026-11-24T02-42-57Z_research_cloudflare/design-magic-environment.md @@ -0,0 +1,11 @@ +# MOVED — 2026-10-25 + +This design doc (v1, 2026-10-21) was fully reviewed and rewritten as v2 and +moved to its canonical home in the Atlas project: + +**hatch-personal repo → workspace/turso-atlas/docs/design-magic-environment.md** +(dezren39/hatch-personal on GitHub, committed and pushed.) + +Note: this file's old location sat under workspace/* in the dezren39/hatch +repo, which is gitignored — v1 was never committed or backed up. The Atlas +docs home (above) is the tracked, pushed location for this design from now on. diff --git a/doc/2026-11-24T02-42-57Z_research_cloudflare/docs/ideas.md b/doc/2026-11-24T02-42-57Z_research_cloudflare/docs/ideas.md new file mode 100644 index 000000000..35ba6d4ba --- /dev/null +++ b/doc/2026-11-24T02-42-57Z_research_cloudflare/docs/ideas.md @@ -0,0 +1,81 @@ +# Cloudflare ideas — parked for future consideration + +Recorded 2026-10-26 at Drew's request. These came up during the +Cloudflare chat's Oct 2026 work (Lab Ops Hub, containers, Atlas +design). **None are approved or scheduled** — this file exists so the +ideas aren't lost. Each entry: what it is, why it surfaced, what it +builds on, and the smallest first step if it's ever picked up. + +## 1. Personal link/file vault + +A personal "save it for later" service on the Workers stack: send it a +URL or a file, it keeps both safe and findable. D1 as the catalog, R2 +for the bytes, KV for the hot index, a Queue for async processing +(content extraction, hashing, later embeddings), a Durable Object for +live state. + +- Why: Lab Ops Hub already implements most of the machinery + (file upload → R2 → queue-driven indexing → D1; container crawl → + stored extract). The vault is that demo generalized into a tool + used daily instead of a surface tour. +- First step if picked up: decide what "save" captures for a URL — + bookmark only, extracted text (the crawler already does this), or a + full snapshot in R2 — then fork the Lab Ops Hub project as the base. + +## 2. Email Workers → D1/R2 pipeline + +Inbound mail to Drew's own domains, handled by Email Routing + +Email Workers: headers and metadata indexed in D1, bodies and +attachments stored in R2, a Queue feeding classification and +summarization. A searchable, owned mail archive plus alert +extraction, independent of Gmail. + +- Why: builds directly on Drew's existing id-mail work, and + complements the Daily Gmail summary goal with infrastructure he + owns end-to-end for his own domains' mail. +- First step if picked up: choose one domain + one address rule and + land the metadata-only version (no body storage) as the spike. + +## 3. D1 as its own thread + +Promote D1 from a sub-topic of the Cloudflare chat to a dedicated +line of work: scheduled export-to-R2 backups (the Cloudflare +Workflows pattern) as the standard exit ramp, read replicas (note: +billable from 2027-03-01), the Sessions API, and D1's settled Atlas +role — the Workers-native projection tier (catalog, hot metadata, +cached answers) beside Turso and Postgres. + +- Why: D1 questions kept recurring (no raw .sqlite download, export + semantics, where it fits vs Turso) and Atlas gives it a permanent + job; it deserves its own home instead of scattered answers. +- First step if picked up: implement scheduled export-to-R2 for + labops-db as the reference instance, then generalize. + +## 4. Workflows for cluster-bootstrap pipelines + +Use Cloudflare Workflows (durable steps, retries, waits, human +approval pauses) to orchestrate the lab-cluster standup pipeline — +the talm / talos / cozystack / postgres / rustfs goal — where +provisioning is long-running, multi-step, and failure-prone in the +middle. + +- Why: the bootstrap is exactly the shape Workflows exists for, and + it would give the cluster work a resumable, observable spine + instead of shell sessions. +- First step if picked up: map the existing bootstrap runbook to + workflow steps on paper and check the fit against the lab cluster + goal's current state before writing code. + +## 5. Sandbox SDK / Artifacts for agent code execution + +Cloudflare's Sandbox SDK (with Artifacts as the git-backed versioned +storage layer) as an execution home for agent-generated code: run +untrusted or experimental code at the edge instead of on Drew's +machines, with versioned artifacts per run. + +- Why: the agent fleet keeps growing, and Lab Ops Hub proved the + account and patterns; a managed sandbox tier would complement the + local/OpenCode execution paths and the containers work. +- First step if picked up: a minimal spike — one Worker driving one + sandbox session — measuring cold start, limits, and cost against + the $5 Workers Paid tier before committing to anything. diff --git a/doc/2026-11-24T02-42-57Z_research_cloudflare/docs/research-containers-do-costs.md b/doc/2026-11-24T02-42-57Z_research_cloudflare/docs/research-containers-do-costs.md new file mode 100644 index 000000000..04db35318 --- /dev/null +++ b/doc/2026-11-24T02-42-57Z_research_cloudflare/docs/research-containers-do-costs.md @@ -0,0 +1,318 @@ +# Cloudflare Containers billing + Durable Objects real-world costs + +Researched 2026-10-20 from official Cloudflare documentation. Every factual claim carries its +source URL. Anything not found on an official page is flagged **UNVERIFIED**. + +Primary sources: + +- Containers pricing: https://developers.cloudflare.com/containers/platform/pricing/ +- Containers FAQ: https://developers.cloudflare.com/containers/faq/ +- Container class API: https://developers.cloudflare.com/containers/api/container-class/ +- Containers limits / instance types: https://developers.cloudflare.com/containers/platform/limits/ +- Durable Objects pricing: https://developers.cloudflare.com/durable-objects/platform/pricing/ +- Workers pricing (plan-level statements + DO section): https://developers.cloudflare.com/workers/platform/pricing/ + +--- + +## Part A — Containers billing + +### A1. Included amounts and overage rates (Workers Paid) + +Containers have **no Free-plan allocation** (Free column is "N/A"); the included amounts below +come with the $5/month Workers Paid plan. Billing is metered **every 10 ms** that an instance is +actively running. + +| Meter | Included / month (Workers Paid) | Overage rate | Equivalent | +|---|---|---|---| +| Memory | 25 GiB-hours | $0.0000025 per GiB-second | $0.009 per GiB-hour | +| CPU (vCPU) | 375 vCPU-minutes | $0.000020 per vCPU-second | $0.072 per vCPU-hour | +| Disk | 200 GB-hours | $0.00000007 per GB-second | $0.000252 per GB-hour | + +Source: https://developers.cloudflare.com/containers/platform/pricing/ + +Key mechanics from the same page: + +- **Memory and disk are billed on provisioned resources** for the instance type selected — + you pay for the size you picked, running idle or not, for as long as the instance is up. +- **CPU is billed on active usage only** — an idle-but-running instance accrues memory and + disk charges but ~zero CPU charges. +- On top of the container meters, "incoming requests to your containers are handled by your + Worker, and each container has its own Durable Object. You are billed for your usage of + both Workers and Durable Objects." Container logs are billed at Workers Logs rates. + +Source: https://developers.cloudflare.com/containers/platform/pricing/ + +### A2. Billing increment and what counts as billable time + +- **Smallest billing increment: 10 ms.** "Containers are billed for every 10ms that they are + actively running." +- **When the clock starts:** "charges start when a request is sent to the container or when + it is manually started." The clock therefore starts at the start request, not when your + process finishes booting — cold-start/provisioning time falls inside the billable window + for the provisioned memory/disk meters (the pricing page does not itemise provisioning + separately; this is the direct reading of the two statements above). +- **When the clock stops:** "Charges stop after the container instance goes to sleep, which + can happen automatically after a timeout." +- **Idle time counts.** An instance that has started and is sitting idle is still "running": + memory and disk (provisioned) keep accruing until the instance sleeps/stops. Only CPU + drops to ~zero while idle, because CPU is usage-based. This is the entire reason + `sleepAfter` is the main cost lever. + +Source: https://developers.cloudflare.com/containers/platform/pricing/ + +### A3. Instance lifetime mechanics — `sleepAfter` + +- `sleepAfter` (Container class property, `string | number`, **default `"10m"`**): "how long + to keep the container alive without activity before shutting it down. Accepts a number of + seconds or a duration string such as `"30s"`, `"5m"`, or `"1h"`. Activity resets the + timer." It can also be reset manually via `renewActivityTimeout()`. When the timer expires, + `onActivityExpired()` fires; the default implementation calls `stop()`. + Source: https://developers.cloudflare.com/containers/api/container-class/ +- With the lower-level Durable Object Container API the equivalent is + `setInactivityTimeout()`; the runtime stops the container after the Durable Object becomes + inactive. Source: https://developers.cloudflare.com/containers/concepts/architecture/ +- **Minimum / maximum `sleepAfter`:** the Container class documentation publishes **no + minimum and no maximum** — only the formats above. **UNVERIFIED** beyond that. (For + comparison, the Sandbox docs — a different product built on the same Durable Object + Container API — state the inactivity timeout works "up to 6 hours": + https://developers.cloudflare.com/sandbox/concepts/lifetime/ . Do not assume the same cap + is documented for Containers' `sleepAfter` property; it is not on the Containers pages.) +- **Minimum billable duration per start:** none published. There is no per-start or + per-request fee for the container itself on the pricing page — billing is purely the + 10 ms-metered memory/CPU/disk above (plus the separate Worker + Durable Object charges + for the fronting Worker and the container's own DO). Source (by inspection of the full + rate card): https://developers.cloudflare.com/containers/platform/pricing/ + +### A4. Worked example — one `lite` instance + +`lite` instance specs (official): **1/16 vCPU, 256 MiB memory, 2 GB disk**. +Source: https://developers.cloudflare.com/containers/platform/pricing/ and +https://developers.cloudflare.com/containers/platform/limits/ +(Full table: lite 1/16 vCPU / 256 MiB / 2 GB · basic 1/4 / 1 GiB / 4 GB · standard-1 1/2 / +4 GiB / 8 GB · standard-2 1 / 6 GiB / 12 GB · standard-3 2 / 8 GiB / 16 GB · standard-4 4 / +12 GiB / 20 GB.) + +**How many instance-hours does the included allowance buy for `lite`?** +All three meters bind at the same point, by design: + +- Memory: 25 GiB-h ÷ 0.25 GiB = **100 instance-hours** +- Disk: 200 GB-h ÷ 2 GB = **100 instance-hours** +- CPU (only if pegged at the full 1/16 vCPU the whole time): 375 vCPU-min = 22,500 vCPU-s + ÷ (1/16) = 360,000 s = **100 instance-hours** + +→ The Workers Paid included allowance buys exactly **~100 lite-instance-hours per month** +(≈ 4.2 days of continuous running). After that you pay overage. + +**One lite instance running continuously for a 30-day month (720 h = 2,592,000 s):** + +| Meter | Usage | Included | Overage qty | Overage cost | +|---|---|---|---|---| +| Memory | 0.25 GiB × 720 h = 180 GiB-h | 25 GiB-h | 155 GiB-h = 558,000 GiB-s | 558,000 × $0.0000025 = **$1.40** | +| Disk | 2 GB × 720 h = 1,440 GB-h | 200 GB-h | 1,240 GB-h = 4,464,000 GB-s | 4,464,000 × $0.00000007 = **$0.31** | +| CPU (worst case: pegged at 1/16 vCPU 24/7) | 2,592,000 s × 1/16 = 162,000 vCPU-s | 22,500 vCPU-s | 139,500 vCPU-s | 139,500 × $0.00002 = **$2.79** | +| CPU (typical: mostly idle) | ~0 active vCPU-s | — | ~0 | **~$0** | + +- Always-on lite, CPU pegged the whole month: **≈ $4.50/month in overage** on top of the + $5 plan (plus the small Worker/DO charges for the container's own Durable Object). +- Always-on lite, CPU mostly idle: **≈ $1.71/month in overage** — memory + disk only. + +**Container network egress** (separate meter, per month): + +| Region | Included allotment | Price per GB after | +|---|---|---| +| North America & Europe | 1 TB | $0.025 | +| Oceania, Korea, Taiwan | 500 GB | $0.05 | +| Everywhere else | 500 GB | $0.04 | + +Source: https://developers.cloudflare.com/containers/platform/pricing/ +(Note the contrast: Workers/R2 egress is free; container egress is the exception — see B1.) + +### A5. Maximum instance lifetime + +- **There is no fixed maximum runtime.** "Cloudflare does not stop a container instance + after a fixed maximum runtime." An instance runs until it is stopped (inactivity timeout, + `stop()`/`destroy()`/`signal()`, rollout) or the platform stops it. +- **But no uptime is guaranteed either:** "a host server restart happens on an irregular + cadence. Cloudflare does not guarantee that any container instance will run for a set + period." On any platform stop, the main process gets **SIGTERM, up to 15 minutes to + exit, then SIGKILL**. Disk is ephemeral — a restarted instance comes back with a fresh + disk from the image (snapshots/FUSE-to-R2 are the persistence options). + +Source: https://developers.cloudflare.com/containers/faq/ + +--- + +## Part B — Durable Objects costs in real use + +### B1. Full rate card (Workers Paid) + +Source for the whole table: https://developers.cloudflare.com/durable-objects/platform/pricing/ +(page updated 2026-10-18; cross-checked against +https://developers.cloudflare.com/workers/platform/pricing/) + +**Compute** + +| Meter | Workers Free | Workers Paid — included | Workers Paid — overage | +|---|---|---|---| +| Requests | 100,000 / day | 1 million / month | **$0.15 / million** | +| Duration | 13,000 GB-s / day | 400,000 GB-s / month | **$12.50 / million GB-s** | + +- "Requests" includes HTTP requests, RPC sessions, WebSocket messages, and **alarm + invocations**. Each RPC method call on a stub is its own RPC session = 1 billed request + (calls on a returned `RpcTarget` stub ride the same session and are not billed again). +- **Incoming WebSocket messages are billed at a 20:1 ratio** (100 incoming messages = 5 + billed requests). A request is charged to establish the WebSocket. **Outgoing WebSocket + messages are free**, and incoming WebSocket protocol pings are not charged. +- **Duration is wall-clock time while the object is active, billed at a flat 128 MB + allocation** regardless of actual memory use — even if several objects share one isolate's + 128 MB, each is billed as if allocated the full 128 MB. +- **Rounding gotcha:** billable usage above the included amount is **rounded up to the next + billable unit** before pricing — the docs' own example rounds 500,000 billable GB-s up to + 1,000,000 GB-s. In practice, *any* duration overage costs a minimum of $12.50, and any + request overage a minimum of $0.15, per month. + +**Storage — SQLite backend (recommended; the only backend on Free)** + +| Meter | Workers Free | Workers Paid — included | Workers Paid — overage | +|---|---|---|---| +| Rows read | 5 million / day | 25 billion / month | **$0.001 / million rows** | +| Rows written | 100,000 / day | 50 million / month | **$1.00 / million rows** | +| SQL stored data | 5 GB total | 5 GB-month | **$0.20 / GB-month** | + +- Rates match D1. The key-value-style methods (`get`/`put`/`delete`/`list`) run against a + hidden SQLite table and are billed as rows read/written. +- **Each `setAlarm()` is billed as one row written.** Deletes count as rows written. +- Writes are 1,000× the read price — the single most asymmetric meter in the stack. +- Stored data is billed until removed; even an empty SQLite database is ~12 KB, and + internal metadata tables count toward billable storage. + +**Storage — legacy key-value backend (Paid only)** + +| Meter | Included | Overage | +|---|---|---| +| Read request units (4 KB = 1 unit) | 1 million | $0.20 / million | +| Write request units | 1 million | $1.00 / million | +| Delete requests | 1 million | $1.00 / million (deletes unmetered by size: one charge per delete call) | +| Stored data | 1 GB | $0.20 / GB-month | + +List operations are billed as read units by data examined; cache hits and multi-key +`get`/`put`/`delete` are billed as if each key were an individual request. `setAlarm` = +1 write request unit. + +**Data transfer:** there is **no inbound or outbound data-transfer meter for Durable +Objects**. The Workers Paid plan states: "There are no additional charges for data +transfer (egress) or throughput (bandwidth)" — Durable Objects are part of that plan, and +the DO pricing page lists no transfer line item. (Containers, above, are the exception.) +Source: https://developers.cloudflare.com/workers/platform/pricing/ + +### B2. Worked examples + +**(a) One always-on, non-hibernating 128 MB Durable Object, 30-day month** + +- Duration: 2,592,000 s × 0.125 GB = **324,000 GB-s** — inside the 400,000 GB-s included + allowance → **$0 duration cost**. (31-day month: 334,800 GB-s, still inside.) +- Requests: only whatever traffic keeps it awake — e.g. a 1-request/minute heartbeat = + 43,200 requests, inside the 1M included → $0. +- **Total: $0 on top of the $5 plan minimum.** What dominates: duration is the only + meaningful meter, and one always-on object consumes ~81% of the account's *entire* + included duration pool. A **second** always-on object pushes the account to ~648,000 + GB-s → 248,000 billable → rounded up to 1,000,000 GB-s → **+$12.50/month**. Always-on + objects are effectively "first one free, each additional ≈ $12.50" (before rounding + effects at larger counts). + +**(b) Hibernating WebSocket room: 100 clients, 1 message/minute each, 24/7** + +Assumptions (matching Cloudflare's own Example 4 modelling): hibernatable WebSockets via +`state.acceptWebSocket()`, ~10 ms of handler execution per message, clients connect once +and stay connected all month through hibernation. + +- Incoming messages: 100 × 60 × 24 × 30 = 4,320,000 → at the 20:1 ratio = **216,000 billed + requests**; +100 connection-establishment requests = 216,100 — inside 1M included → $0. +- Outgoing broadcasts: free. Protocol pings: free. +- Duration: the object is only active while handling — 100 msgs/min × 10 ms = 1 s per + minute → 43,200 s/month × 0.125 GB = **5,400 GB-s** — inside included → $0. +- **Total: ≈ $0 on top of the $5 plan.** What dominates: **requests** (216k of the 1M + included pool) — hibernation collapses the duration meter to ~1.7% of the always-on + figure for the same room (5,400 vs 324,000 GB-s). +- Contrast at scale, from Cloudflare's own worked examples (100 Durable Objects, 50–100 + clients each, 1 msg/min): **without** hibernation $142.95/month (duration $137.50 of it); + **with** WebSocket Hibernation $20.65/month (duration $12.50, requests $3.15). + Source: https://developers.cloudflare.com/durable-objects/platform/pricing/ (Examples 2 + and 4) + +**(c) Coordination-only Durable Object that stores nothing** + +Pass-through pattern: the Worker/DO receives a call and forwards it (e.g. to R2 or another +service) without touching DO storage. Cost = requests + the brief duration while your +handler executes. Example at volume: 10 million RPC calls/month, 5 ms handling each: + +- Requests: 10M − 1M included = 9M × $0.15/M = **$1.35** +- Duration: 10,000,000 × 0.005 s = 50,000 s × 0.125 GB = 6,250 GB-s → inside included → $0 +- Storage: **$0** — no rows written, nothing stored. (Caveats: if you call `setAlarm()` it + counts as a row written; an object that never writes still avoids storage charges + entirely.) +- **Total ≈ $1.35/month overage.** What dominates: **requests, by a mile.** A + store-nothing coordinator is the cheapest DO pattern there is — duration only accrues + for the milliseconds your code is actually running, and the artifact/data path + (Worker → R2) never touches the DO's disk or storage meters at all. + +### B3. Hibernation mechanics + +Sources: https://developers.cloudflare.com/durable-objects/platform/pricing/ (Compute +billing + footnotes + FAQ) unless noted. + +- **What stops the duration meter:** duration is billed for wall-clock time while the + object is *actively executing JavaScript* (handling a request or running event handlers) + **or** *idle in memory but unable to hibernate*. An idle object that is **eligible** for + hibernation is **not billed for duration, even before the runtime actually hibernates + it**. Inactive objects receiving no requests incur no duration charges at all. +- **The WebSocket trap:** calling `accept()` on a WebSocket "will incur duration charges + for the entire time the WebSocket is connected." Use the **WebSocket Hibernation API** + (`state.acceptWebSocket()`) so the object can hibernate while connections stay open; + the runtime wakes it when a message arrives. +- **Auto-responses are free time:** messages handled by `state.setWebSocketAutoResponse()` + (e.g. heartbeat ping/pong) "will not incur additional wall-clock time, and so they will + not be charged" — the object doesn't even wake. +- **What wakes a hibernated object:** a request routed to it ("Requests to a Durable + Object keep it active or create the object if it was inactive"), an incoming message on + a hibernatable WebSocket, or an alarm firing. On wake, the constructor runs again — + in-memory state is gone and must be rebuilt from storage. +- **What blocks hibernation / keeps the meter running:** + - WebSockets accepted with `accept()` instead of the Hibernation API (billed for the + whole connection lifetime). + - **Pending I/O:** "Pending I/O operations keep an object in memory for up to 15 + minutes each. The object incurs duration charges during that time." (Corroborated by + the compatibility-flags docs: pending service-binding requests, DO RPC calls, + `container.monitor()`, and `ctx.waitUntil()` promises each prevent eviction until + completion or a 15-minute cap: + https://developers.cloudflare.com/workers/configuration/compatibility-flags/) + - Actively executing handlers — duration is shared across all requests concurrently + active on the object (it is wall-clock, not per-request summed). +- **Do alarms bill duration?** Partially, in three small pieces: + - The alarm **invocation counts as a request** (requests meter includes alarm + invocations). + - Each **`setAlarm()` call is billed as one row written** (SQLite backend) or one write + request unit (KV backend) — even if you store nothing else. + - While the **alarm handler is executing**, the object is actively running JavaScript, + so duration accrues for those milliseconds — same as any handler. Between alarms, an + idle hibernation-eligible object accrues nothing. A short handler on a sparse alarm + is effectively free; the meter to watch is a high-frequency alarm cadence eating the + requests allowance (e.g. a 30-second keep-alive heartbeat = 86,400 requests/month). + +--- + +## Headline numbers + +- **Containers (Workers Paid):** 25 GiB-h memory, 375 vCPU-min, 200 GB-h disk included; + overage $0.0000025/GiB-s, $0.000020/vCPU-s, $0.00000007/GB-s; billed per 10 ms; memory & + disk on provisioned size (idle counts), CPU on active use only. +- Included container allowance = **exactly ~100 lite-instance-hours/month**; an always-on + lite costs ≈ **$1.71/mo overage idle-CPU, ≈ $4.50/mo with CPU pegged**. No maximum + instance runtime — but no uptime guarantee (SIGTERM + 15 min grace on host stops). +- **Durable Objects (Workers Paid):** 1M requests (+$0.15/M) and 400,000 GB-s duration + (+$12.50/M GB-s) included; SQLite rows read 25B incl. (+$0.001/M), rows written 50M + incl. (+$1.00/M), stored 5 GB-mo incl. (+$0.20/GB-mo); no egress charges. +- One always-on DO ≈ 324,000 GB-s/month = **free alone, ~$12.50/mo for each additional** + (rounding makes any duration overage cost at least $12.50). Hibernation cuts a busy + WebSocket room's duration by ~98%; a store-nothing coordination DO is billed almost + entirely on requests ($0.15/M). diff --git a/doc/2026-11-24T02-42-57Z_research_cloudflare/docs/research-declarative-infra.md b/doc/2026-11-24T02-42-57Z_research_cloudflare/docs/research-declarative-infra.md new file mode 100644 index 000000000..5bfb0c50a --- /dev/null +++ b/doc/2026-11-24T02-42-57Z_research_cloudflare/docs/research-declarative-infra.md @@ -0,0 +1,407 @@ +# Declarative ways to build Cloudflare infrastructure — and templates another person can run + +Researched 2026-10-20. Every claim is tied to a source URL. Items I could not verify +from a primary source are flagged **UNVERIFIED**. "GA" vs "beta" is called out explicitly. + +**Short version:** for a Worker-centric app, the repo itself is already the template: +`wrangler.jsonc` + Wrangler's automatic provisioning (or the Deploy to Cloudflare button +for zero-local-tooling). Terraform/Pulumi are the only routes that also manage zones, +DNS, WAF and account settings. Alchemy and SST sit in between: TypeScript-native, +Cloudflare-focused (Alchemy) or multi-cloud (SST), at the cost of an extra toolchain — +and Alchemy v2 is still in beta. + +--- + +## 1. Wrangler config (`wrangler.jsonc`) as declarative infrastructure + +Wrangler's docs explicitly position the config file as the source of truth for a Worker: +"It is best practice to treat Wrangler's configuration file as the source of truth for +configuring a Worker." One file declares the Worker name, entrypoint, compatibility +date, routes/custom domains, cron triggers, static assets, observability, and every +binding. +Source: https://developers.cloudflare.com/workers/wrangler/configuration/ + +### What the config can declare + +Binding/resource sections documented in the configuration reference include: + +- **Compute/app**: the Worker script itself, routes, cron `triggers`, static `assets`, + `vars`, service bindings, `observability`, `placement`, `limits` +- **Storage**: `kv_namespaces`, `d1_databases`, `r2_buckets`, `analytics_engine_datasets` + (Analytics Engine), `hyperdrive`, `vectorize`, AI Search namespaces/instances +- **State/messaging**: `durable_objects` (bindings + `migrations` or the newer `exports`), + `queues` (producers and consumers), `workflows` +- **AI/media**: `ai` (Workers AI binding — no resource to create, it's just a binding), + Browser Run, Images, mTLS certificates, Secrets Store / `secrets` +- **Containers**: a `containers` section declaring the image (Dockerfile path or a + pre-built registry image), `instance_type`, `max_instances` and scheduling policy, + attached to a Durable Object class +- **Platform**: dispatch namespaces (Workers for Platforms), email bindings/addresses, + environments (`env.` overrides for staging etc.) + +Source: https://developers.cloudflare.com/workers/wrangler/configuration/ +(binding list cross-checked against the reference's section list: D1, KV, R2, Queues, +Durable Objects, Hyperdrive, Vectorize, Workers AI, Workflows, Containers, Analytics +Engine, static assets, service bindings). + +### Auto-created vs must pre-exist + +**Automatic provisioning (the big change).** If a binding in the config has *no resource +ID*, Wrangler creates the resource for you: + +- The configuration reference states: "Wrangler can automatically provision resources + for you when you deploy your Worker… This currently works for the following resources: + KV, R2, D1, Flagship, AI Search, Agent Memory, Dispatch Namespaces and Queues." + Resources are created with the Worker name as prefix; on `wrangler deploy` the new IDs + are written back into the config file; `wrangler dev` creates local equivalents that + persist between runs. + Source: https://developers.cloudflare.com/workers/wrangler/configuration/ (Automatic + provisioning section) +- The feature launched 2025-10-24 as an **open beta** covering KV, R2 and D1, requiring + wrangler ≥ 4.45.0, disable-able with `--no-x-provision`; the changelog also calls out + the template angle: "resources will stay linked across future deploys even without + adding the resource IDs to the config file. This is especially useful for shared + templates, which now no longer need to include account-specific resource IDs." + Source: https://developers.cloudflare.com/changelog/2025-10-24-automatic-resource-provisioning/ + The current configuration reference lists a wider resource set and presents it without + a beta label; whether it has formally graduated from beta is **UNVERIFIED** beyond the + docs presentation. + +**Created by deploy itself:** + +- Durable Object namespaces/classes are created by declaring the binding plus a + migration (or the newer `exports` key); there is no separate "create DO" step. + Source: https://developers.cloudflare.com/workers/wrangler/configuration/ +- Container applications: declaring the `containers` block and running + `wrangler deploy` builds the image (or uses the referenced registry image) and + creates/updates the container application. + Source: https://developers.cloudflare.com/workers/wrangler/configuration/ +- Queues are now in the auto-provisioning list above. Workers AI needs nothing created. + +**Must pre-exist (not auto-provisioned by `wrangler deploy`):** + +- **Hyperdrive** — the config binding takes "the ID of the Hyperdrive configuration", + i.e. a Hyperdrive config (which wraps an existing external Postgres/MySQL database + and its credentials) must be created first (`wrangler hyperdrive create`, dashboard, + or Terraform's `cloudflare_hyperdrive_config`). + Source: https://developers.cloudflare.com/workers/wrangler/configuration/ (Hyperdrive + binding section) +- **Vectorize** — not in the Wrangler auto-provisioning list; the binding references an + existing index (`index_name`) created beforehand via `wrangler vectorize create` or + the dashboard. (Note: the *Deploy button* flow below does list +...[truncated 14597 chars] Vectorize among the resources it provisions — the two flows have different lists.) +- **The target zone** for any route or custom domain must already exist and be active + in the account; Wrangler does not create zones or DNS. +- **Secrets** are never in the config: they are set out-of-band with + `wrangler secret put` / `wrangler secret bulk` (locally, `.dev.vars`). + Source: https://developers.cloudflare.com/workers/wrangler/configuration/ + +### Reproducibility for another person + +Clone → `npm install` → `npx wrangler login` (OAuth) *or* set +`CLOUDFLARE_API_TOKEN` + `CLOUDFLARE_ACCOUNT_ID` → `npx wrangler deploy`. +With ID-less bindings, the deploy provisions KV/R2/D1/Queues/etc. into *their* account +and writes the fresh IDs back into their local config copy. `wrangler dev` runs the +same config locally (Miniflare/workerd emulation) with locally-provisioned resources. +This is the lowest-friction route that still leaves the user in control of a normal +git repo. The committed `wrangler.jsonc` should ship bindings *without* IDs (or with +clearly-placeholder IDs) so each deployer gets their own resources. + +### What Wrangler does NOT manage + +Zones, DNS records, zone settings, WAF/firewall rules, cache rules, Page Rules, +account membership/settings, Registrar domains, Tunnels/Access policy (beyond binding +a Worker), and billing plans. That gap is what Terraform/Pulumi fill. + +--- + +## 2. Terraform — `cloudflare/cloudflare` provider + +**Status: GA, currently v5.x** (Cloudflare docs examples pin `~> 5` and `~> 5.19`; +`cloudflare_workflow` was added in provider v5.11.0, 2025-10-09). +Sources: https://developers.cloudflare.com/pipelines/reference/terraform/ · +https://developers.cloudflare.com/changelog/2025-10-09-workflows-terraform/index.md + +### Breadth — the widest of any option here + +The provider manages the layers Wrangler doesn't, plus most of the developer platform: + +- **Zones & DNS**: `cloudflare_zone`, `cloudflare_dns_record`, zone settings + (`cloudflare_zone_setting`), rulesets, Page Rules, cache/Tiered Cache, SSL/cert packs +- **Security/network**: WAF rulesets, firewall rules, rate limiting, Bot Management, + API Shield, Load Balancers + pools/monitors, Spectrum, Argo/Tiered Cache, + Magic Transit/WAN resources, Tunnels (`cloudflare_tunnel_config` in Cloudflare One docs) +- **Zero Trust / Access**: `cloudflare_zero_trust_access_application`, groups, policies, + identity providers, Gateway +- **Developer platform**: `cloudflare_workers_script`, `cloudflare_workers_route`, + `cloudflare_workers_kv_namespace`, `cloudflare_d1_database`, `cloudflare_r2_bucket` + (+ R2 CORS/lifecycle/event notifications, R2 Data Catalog), `cloudflare_queue` + + `cloudflare_queue_consumer`, `cloudflare_hyperdrive_config`, + `cloudflare_pages_project`, `cloudflare_workflow`, Pipelines resources + (`cloudflare_pipeline`, `_stream`, `_sink`) +- **Account/admin**: `cloudflare_account`, account tokens (`cloudflare_account_token`, + `cloudflare_api_token`), account members, notification policies, Registrar domains, + Stream, Images + +Sources: https://developers.cloudflare.com/changelog/product/terraform/ (resource names +in release notes) · https://developers.cloudflare.com/tunnel/guides/terraform/ · +https://developers.cloudflare.com/pipelines/reference/terraform/ · +https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/workflow + +Worker *code* in Terraform is clunky compared to Wrangler: `cloudflare_workers_script` +takes built file content + `content_sha256`, and the newer granular +`cloudflare_worker_version` / deployment resources were still labelled **beta** in the +2025-10-09 changelog. +Source: https://developers.cloudflare.com/changelog/2025-10-09-workflows-terraform/index.md + +### State & maturity caveats + +- Standard Terraform state rules apply: the state file is a local `terraform.tfstate` + unless *you* configure a remote backend (for a team, you must). Nothing Cloudflare- + specific hosts it for you. Auth is an API token passed to the provider + (`api_token`, sourced from env in practice). + Sources: https://developers.cloudflare.com/pipelines/reference/terraform/ (provider + block + token variable) · https://developers.cloudflare.com/terraform/llms-full.txt + (official tutorial series: init → plan/apply → track history/state guidance) +- **v5 had a publicly rocky launch.** Cloudflare's own changelog (2025-08-29, v5.9, and + repeated in the 2025-11-20 v5.13 notes) acknowledges "the high number of issues + reported by the Cloudflare community related to the v5 release" and commits to a + 2–3 week stabilization cadence with a resource-by-resource stabilization programme. + Treat v5 as GA-but-still-hardening; pin versions and read the per-release notes. + Source: https://developers.cloudflare.com/changelog/product/terraform/ +- **cf-terraforming** is Cloudflare's official Go tool (built on cloudflare-go) that + reads an existing account/zone and *generates* Terraform config + import statements, + for adopting Terraform over hand-built infrastructure. + Source: https://blog.cloudflare.com/introducing-cf-terraforming/ + +**Verdict:** the right tool for the zone/DNS/security/account layer and for +multi-cloud estates; overkill and worse DX if the whole estate is one Worker app. + +--- + +## 3. Pulumi — `@pulumi/cloudflare` + +**Status: GA; v6.22.1 (published 2026-10-13 per the Pulumi Registry).** +Source: https://www.pulumi.com/registry/packages/cloudflare/ + +- Official Pulumi package in TypeScript, Python, Go, .NET and Java. It is a bridge of + the Terraform provider — the registry's package details state "This Pulumi package is + based on the `cloudflare` Terraform Provider" — so resource breadth tracks + Terraform's (zones, DNS, Workers, R2, D1, Zero Trust, Tunnels…), with the same + coverage lag. Cloudflare's own Pulumi tutorial demonstrates a *dynamic provider* + workaround for a resource the provider didn't support yet (Vectorize), and pairs + Pulumi with Wrangler for Worker deployment. + Sources: https://www.pulumi.com/registry/packages/cloudflare/api-docs/tunnel/ + (package details note) · + https://developers.cloudflare.com/pulumi/tutorial/dynamic-provider-and-wrangler/ +- State: Pulumi's model — Pulumi Cloud, or a self-managed backend (file/S3/R2-style) + that you configure; stacks give you dev/stage/prod separation. + +**Verdict:** choose it if you are already a Pulumi shop or want infra in a general- +purpose language with components; for a Cloudflare-only solo project it adds state +machinery that Wrangler/Alchemy don't need. + +--- + +## 4. SST (sst.dev) + +**Status: GA framework (SST v3, built on Pulumi); Cloudflare is a supported but +second — to AWS — provider.** +Sources: https://sst.dev/docs/cloudflare/ · +https://sst.dev/docs/component/cloudflare/worker/ + +- Setup: `sst add cloudflare` adds the Cloudflare provider to `sst.config.ts`. SST + consumes the Cloudflare Pulumi/Terraform provider — the docs example pins + `providers: { cloudflare: "5.37.1" }`. + Source: https://sst.dev/docs/cloudflare/ +- **Components** under `sst.cloudflare.*`: `Worker` (handler path, esbuild bundling, + `url: true`, `link: [...]`, custom domains, assets) plus D1, KV, R2 and framework + components (e.g. `sst.cloudflare.Remix`). "Linking" a resource to a Worker injects + access via SST's `Resource` SDK instead of raw bindings. + Sources: https://sst.dev/docs/component/cloudflare/worker/ · + https://sst.dev/docs/cloudflare/ +- **State can live on Cloudflare itself**: set `home: "cloudflare"` in the app config + and SST stores app state in an R2 bucket in your account. + Source: https://sst.dev/docs/cloudflare/ +- **Credentials**: an account API token; SST's Cloudflare guide says to create it from + the **"Edit Cloudflare Workers"** token template and add permissions such as + *Account – D1 – Edit*. + Source: https://sst.dev/docs/cloudflare/ + +**Verdict:** nice if you want SST's component/linking model or one config spanning AWS ++ Cloudflare. For a pure-Cloudflare app it's a heavier stack (SST → Pulumi → TF +provider v5) than the problem needs. + +--- + +## 5. Alchemy (alchemy.run) + +**Status: BETA. Alchemy v2 is a ground-up, Effect-based TypeScript rewrite and is +shipping as `2.0.0-beta.x` (2.0.0-beta.75, Aug 2026, per its own release notes). +Not GA.** +Sources: https://alchemy.run/blog/2026-08-25-beta-75/ · +https://alchemy.run/blog/2026-07-30-beta-66/ + +- Purpose-built for Cloudflare first (it now also targets other clouds). The whole + stack — Worker, D1 (with migrations as part of deploy), KV, R2, Durable Objects, + Containers, Workflows, Queues, Hyperdrive, Pipelines, Vite/static sites — is + declared in one TypeScript program (`alchemy.run.ts`) with typed bindings: + resources are passed directly as a Worker's `env`, and `Cloudflare.InferEnv<...>` + derives the handler's env type so infra and code can't drift. + Sources: https://alchemy.run/cloudflare/ · + https://alchemy.run/cloudflare/compute/workers/ +- Deploy with `bun alchemy deploy`; `alchemy dev` emulates KV/R2/D1/Queues locally + (beta.66+) with per-resource opt-in to real cloud resources. + Source: https://alchemy.run/blog/2026-07-30-beta-66/ +- **State**: stored per stack/stage. Default is local files under `.alchemy/` + (gitignore it; each dev gets their own `dev_$USER` stage). For teams/CI there's a + Cloudflare-backed remote store — `state: Cloudflare.state()` — which persists state + in a Worker backed by a Durable Object with embedded SQLite, credentials kept in + the account's Secrets Store. + Source: https://alchemy.run/state-store/ + +**Verdict:** the most ergonomic "everything in TypeScript, one command" option for a +Cloudflare-native app, and the closest in spirit to "declarative wrangler, but typed +and composable" — weighed against beta status, an Effect-flavoured API learning +curve, and a much smaller community than Wrangler/Terraform. Fine for a solo dev who +accepts beta risk; hard to recommend as the default for other people to run. + +--- + +## 6. Cloudflare's own template ecosystem + +### 6a. Deploy to Cloudflare button — **GA** (launched 2025-04-08) + +A README badge linking to +`https://deploy.workers.cloudflare.com/?url=`. On click, Cloudflare: + +1. **Clones the source repo** (public GitHub/GitLab) into a new repo in the clicker's + own Git account, after they connect GitHub/GitLab and Cloudflare accounts; +2. Lets them customize repository name, Worker name and resource names on one setup + page (reflected in the cloned repo); +3. **Builds and deploys with Workers Builds** (Cloudflare's git-connected CI/CD) — + every later push to the production branch redeploys, and PRs get preview URLs; +4. **Auto-provisions whatever the app's Wrangler config declares.** Per the docs, + supported resources include: KV namespaces, D1 databases, R2 buckets, Hyperdrive, + Vectorize databases, Secrets Store secrets (storage); Durable Objects, Workers AI, + Queues (compute). "Cloudflare will read the Wrangler configuration file of your + source repo to determine resource requirements" and updates the config with new + IDs where applicable. The source repo should ship default values for resource + names/IDs so provisioning succeeds. + +Sources: https://developers.cloudflare.com/workers/platform/deploy-buttons/ · +https://blog.cloudflare.com/deploy-workers-applications-in-seconds/ + +This is also the flow behind dashboard git deploys generally: connect a repo and +Workers Builds deploys on push; the Wrangler config page notes that dashboard/GitHub +deploys also trigger provisioning, except created IDs "will only be accessible via +the dashboard… will not be written back to your repository." +Source: https://developers.cloudflare.com/workers/wrangler/configuration/ + +### 6b. create-cloudflare (C3) — **GA**, official scaffolding + +`npm create cloudflare@latest` — interactive scaffolder for new Workers and Pages +projects. Cloudflare's split of duties: "C3: To create new projects. Wrangler: To +build and deploy your projects." C3 generates `wrangler.jsonc`, `src/index.ts`, +`package.json`, `tsconfig.json`, initializes git, can wire framework starters +(Astro, Next.js, Nuxt, SvelteKit, Remix, Hono, React, Vue, etc.), and offers an +immediate first deploy after login. +Sources: https://developers.cloudflare.com/pages/get-started/c3/ · +https://developers.cloudflare.com/learning-paths/workers/get-started/c3-and-wrangler/ · +https://developers.cloudflare.com/workflows/get-started/guide/ + +The templates C3 offers live in the official `cloudflare/templates` GitHub +repository, which also hosts the create-cloudflare CLI itself. +Source: https://deepwiki.com/cloudflare/templates/3.1-create-cloudflare-cli +(secondary index of the repo; the repo itself is github.com/cloudflare/templates) + +### 6c. Workers playground / dashboard "create from repo" + +The dashboard's Workers & Pages → Create flow (import an existing Git repository) +is the same Workers Builds machinery as the deploy button, minus the badge; the +in-browser Playground is for throwaway experiments, not a distribution mechanism. +(The `workers.new` shortcut historically opened the playground — current behaviour +**UNVERIFIED**, not relied on here.) + +--- + +## 7. Other declarative routes + +- **cf-terraforming** (official, Go, built on cloudflare-go): generates Terraform + config/imports from a live account — an adoption tool, not a runtime. + Source: https://blog.cloudflare.com/introducing-cf-terraforming/ +- **Cloudflare API + cloudflare-go / cloudflare-typescript SDKs**: everything above + ultimately drives the REST API, so a bespoke script is always an option; not + "declarative" in any managed-state sense. No separate source needed — this is the + substrate the Terraform provider and cf-terraforming are built on. +- **Ansible / Crossplane**: no official Cloudflare collection/provider of + significance was found in primary sources during this research — treat as + **UNVERIFIED/marginal** and skip; community modules exist but are not a route to + recommend for this use case. + +--- + +## 8. Practical comparison — "someone clones a repo and runs 1–2 commands" + +### What the other person needs, per route + +| Route | They need | Commands | State to manage | +|---|---|---|---| +| Deploy button | CF account + GitHub/GitLab account | 0 local (clicks only) | None (CF hosts repo copy + Builds) | +| Wrangler config | CF account; Node; `wrangler login` OAuth **or** scoped API token + account ID env vars | `npm install`, `npx wrangler deploy` | None — config file is the state | +| Alchemy | CF account + API credentials; Bun | `bun install`, `bun alchemy deploy` | `.alchemy/` local dir, or CF-backed store | +| SST | CF account API token ("Edit Cloudflare Workers" template + perms) | `npx sst deploy` | SST state (can be an R2 bucket via `home: "cloudflare"`) | +| Terraform | CF API token; Terraform CLI; a state backend decision | `terraform init && terraform apply` | tfstate — **you** must host/share it | +| Pulumi | CF API token; Pulumi CLI + language runtime | `pulumi up` | Pulumi Cloud or self-managed backend | + +### Ranking for a solo dev sharing a Cloudflare app + +1. **Wrangler config + automatic provisioning** — the default. One committed file is + the template; the runner needs only a Cloudflare account and login; no state + files, no extra toolchain; covers the entire Worker-side stack (Workers, D1, R2, + KV, Queues, DOs, Containers, Workflows, AI). Its blind spot is everything + zone/account-level. +2. **Deploy to Cloudflare button** — the absolute lowest friction for *consumers* + of your template (no local tooling at all, broadest auto-provisioning list in + Cloudflare's own docs). Ranked second only because the deployer ends up with a + forked repo + dashboard-managed IDs rather than a clean local-first workflow; + ideal *in addition to* #1 — the same repo supports both. +3. **Alchemy** — best ergonomics for a TypeScript-native, multi-resource app + (typed bindings, D1 migrations in the deploy, stages, local emulation), but + **beta** and Effect-flavoured. Adopt knowingly. +4. **SST** — if you value its component/linking model or may span AWS + Cloudflare; + heavier machinery (SST → Pulumi → TF provider v5) for a CF-only app. +5. **Terraform** — first choice only when the deliverable includes zones, DNS, WAF, + Access/Zero Trust or account settings, or when it's joining an existing + Terraform estate. Worst fit for "just run my Worker app": state backend to set + up, clunky Worker-code story, v5 still stabilizing per Cloudflare's changelog. + A common real-world split: **Terraform for the zone layer + Wrangler for the + app layer.** +6. **Pulumi** — Terraform's breadth in a real programming language; sensible if + you're already on Pulumi, otherwise the same state overhead with a smaller + Cloudflare community than #1–#3. + +### What CANNOT be fully automated (any route) + +- **Having a Cloudflare account** — signup is a human, web flow. Every route assumes + the runner already has one. +- **Paying plans** — e.g. upgrading an account to Workers Paid, and adding a payment + method, is a dashboard/billing action; no IaC tool subscribes you. +- **R2 activation** — R2 requires an R2 subscription added through the dashboard + checkout flow before buckets can be created ("You need a Cloudflare account with + an R2 subscription… Complete the checkout flow to add an R2 subscription"). + Source: https://developers.cloudflare.com/r2/get-started/ +- **The first API token** — token creation is a dashboard act (chicken-and-egg); + only *after* a sufficiently-privileged token exists can Terraform manage further + tokens (`cloudflare_account_token`). `wrangler login` OAuth avoids the token for + interactive use. +- **Domains** — buying a domain (Registrar purchase is a checkout), transferring a + domain in, and changing nameservers at an external registrar are outside IaC; + a zone only becomes active in Cloudflare once nameservers point at it, so routes/ + custom domains in any tool wait on that human/DNS step. +- **Secrets' values** — secret *slots* can be declared, but the values must be + supplied by the runner (`wrangler secret put`, SST/Pulumi/Terraform secret + config); a template can never ship working third-party API keys. +- **Product ToS/first-run gates** — several products have dashboard first-run steps + (R2 above is the documented example); expect an occasional one-time click-through + that no tool can do for a fresh account. diff --git a/doc/2026-11-24T02-42-57Z_research_cloudflare/docs/research-do-practices.md b/doc/2026-11-24T02-42-57Z_research_cloudflare/docs/research-do-practices.md new file mode 100644 index 000000000..a3ffcd19f --- /dev/null +++ b/doc/2026-11-24T02-42-57Z_research_cloudflare/docs/research-do-practices.md @@ -0,0 +1,683 @@ +# Durable Objects — Architecture Truths, Pitfalls, and Best Practices + +Researched 2026-10-20. Primary sources are official Cloudflare docs +(developers.cloudflare.com) and the Cloudflare blog. Community sources are +used second and are explicitly marked **[community]**. Claims I could not +verify against a page I actually opened are flagged **UNVERIFIED**. + +Headline official sources: + +- Rules of Durable Objects (official best-practices guide, updated 2026-10-18): + https://developers.cloudflare.com/durable-objects/best-practices/rules-of-durable-objects/ +- Changelog announcing the guide (2025-12-15): + https://developers.cloudflare.com/changelog/post/2025-12-15-rules-of-durable-objects/ +- Workers / Durable Objects pricing (official): + https://developers.cloudflare.com/workers/platform/pricing/ +- Workers limits (official): https://developers.cloudflare.com/workers/platform/limits/ + +--- + +## 1. Does a Durable Object have to store data in its own storage? (Short answer: No) + +### 1.1 DO storage is optional — a DO can be pure coordination/compute + +Nothing in the platform requires a Durable Object to call its storage API. +A DO is a class with RPC methods / a `fetch()` handler plus a `ctx` object; +`ctx.storage` is an available API, not a toll every object must pay. The +official Rules guide describes three *state layers* a DO may use, one of +which is external storage — i.e. the object's meaningful state can live +entirely outside its own storage: + +| Type | Speed | Persistence | Use case | +| --- | --- | --- | --- | +| In-memory (class properties) | Fastest | Lost on eviction or crash | Caching, active connections | +| SQLite storage | Fast | Durable across restarts | Primary data storage | +| External (R2, D1) | Variable | Durable, cross-DO accessible | Large files, shared data | + +Source: Rules of Durable Objects, +https://developers.cloudflare.com/durable-objects/best-practices/rules-of-durable-objects/ + +Pricing corroborates the "storage is opt-in" model: you are billed for +stored data only while data exists — "Durable Objects will be billed for +stored data until the data is removed. Once the data is removed, the object +will be cleaned up automatically by the system." An object that stores +nothing incurs only request and duration charges. +Source: https://developers.cloudflare.com/workers/platform/pricing/ + +Official examples of DOs that coordinate without persisting through DO +storage: + +- The official **in-memory state example** keeps a counter purely in a class + property and explicitly accepts losing it on eviction — a supported, + documented pattern, not an abuse: + https://developers.cloudflare.com/durable-objects/examples/durable-object-in-memory-state/index.md +- Cloudflare's own **Browser Run + Durable Objects tutorial** has a DO whose + whole job is producing screenshots and writing them straight to R2 — it + never writes the payloads to DO storage (see 1.2). + +### 1.2 Bindings (including R2) work inside DO code exactly as in a Worker + +A DO class receives the Worker's full `env` bindings object as the second +constructor argument (`super(ctx, env)`; in the `DurableObject` base class +it is exposed as `this.env`). Every binding the Worker has — R2 buckets, +D1 databases, KV namespaces, Queues, service bindings, secrets — is +reachable from inside DO methods. This is not a trick; it is how +Cloudflare's own tutorials are written. + +Proof from an official tutorial: the Browser Run DO declares +`BUCKET: R2Bucket` in its `Env` interface, and inside the DO's `fetch()` +handler writes browser screenshots directly to the bucket: + +```ts +await this.env.BUCKET.put(`${folder}/${fileName}.jpg`, sc); +``` + +Source (official tutorial): +https://developers.cloudflare.com/browser-run/how-to/browser-run-with-do/ + +So: **a DO can pass data forward into R2 without the bytes ever touching +DO storage or "the DO's disk."** The DO is compute + coordination; R2 is +the blob store. (A DO has no user-visible disk at all — its only "disk" is +the optional storage API.) + +### 1.3 Streaming data *through* a Worker or a DO into R2 + +Three distinct data-plane options, in increasing order of "keep bytes away +from your compute": + +**(a) `put()` with a stream (Worker or DO).** The R2 Workers binding accepts +a `ReadableStream` as the value of `put(key, value)`. Cloudflare's official +upload tutorial does exactly this with a request body: + +```ts +await env.MY_BUCKET.put(key, request.body); +``` + +Source (official tutorial): +https://developers.cloudflare.com/workers/tutorials/upload-assets-with-r2/ + +Practical constraint: a single `put()` needs to know the object's length. +A `fetch()` response body that carries `Content-Length`, or a stream +wrapped in the Workers runtime's `FixedLengthStream`, satisfies this; a +chunked/unknown-length stream does not, and the fallback is buffering or +multipart (option b). [community: the FixedLengthStream pattern and the +known-length requirement are spelled out in +https://dev.to/movoa/copy-a-remote-video-into-r2-from-a-cloudflare-worker-without-buffering-it-1fg +— I did not find this exact constraint stated on the R2 docs pages I opened, +so treat the mechanism as documented-by-practitioners rather than quoted +from the R2 reference.] + +**(b) Multipart uploads via the binding (Worker or DO).** For large or +unknown-length payloads, the binding exposes the full multipart API: +`bucket.createMultipartUpload(key)` → `upload.uploadPart(n, streamOrBody)` +per part → `upload.complete(parts)` / `upload.abort()`, and +`bucket.resumeMultipartUpload(key, uploadId)` to continue an upload across +invocations. Parts are a minimum of 5 MB each except the last; uncompleted +multipart uploads are automatically aborted after 7 days. The official +guide's design has the *client* track `uploadId` + part etags and call the +Worker per part — state does not need to live in the Worker at all. +Sources (official): +https://developers.cloudflare.com/r2/api/workers/workers-multipart-usage/ +and the R2 Workers API reference linked from it. + +**(c) Presigned URLs — the data plane bypasses your compute entirely.** +R2 supports S3-style presigned URLs (GET/HEAD/PUT/DELETE; expiry from +1 second to 7 days). They are generated locally with SigV4 signing — "no +communication with R2" is needed to mint one. The client then uploads +directly to `.r2.cloudflarestorage.com`; the bytes never pass +through any Worker or DO. Caveats from the docs: a presigned URL is a +bearer token (anyone holding it can perform the operation until expiry — +use short expiries and pin `Content-Type` in the signature), and presigned +URLs only work on the S3 API domain, not on custom domains. +Source (official): https://developers.cloudflare.com/r2/api/s3/presigned-urls/ +[community note: the AWS SDK presigner shown in the R2 docs does not run +inside the Workers runtime; in-Worker signing is typically done with a +small SigV4 library such as `aws4fetch` — +https://gebna.gg/blog/fix-fs-readfile-is-not-implemented-yet] + +### 1.4 The memory constraint when data flows *through* compute + +- **Both Workers and Durable Objects run in V8 isolates with a hard + 128 MB memory limit per isolate** — same on Free and Paid, not + configurable. Official limits page: "Memory per isolate: 128 MB… This + limit is per-isolate, not per-invocation. A single isolate can handle + many concurrent requests." + Source: https://developers.cloudflare.com/workers/platform/limits/ +- The DO pricing page adds a sharp edge: duration billing assumes the full + 128 MB allocation per object, and "many instances of a single Durable + Object class… may run in the same isolate on the same physical machine + and share the 128 MB of memory. These Durable Objects are still billed + as if they are allocated a full 128 MB of memory." + Source: https://developers.cloudflare.com/workers/platform/pricing/ +- **[community] consequence, well documented in production write-ups:** + because the 128 MB is per *isolate* and isolates are shared, the object + that gets reset for exceeding memory is often not the object that used + the memory ("noisy neighbour" resets), and you cannot profile a + production DO's heap — only after-the-fact GraphQL percentile metrics: + https://polylane.com/blog/how-we-fixed-our-cloudflare-durable-objects-memory-exceeded-errors/ + +What this means for streaming designs: + +- **Buffering is the trap.** `await request.arrayBuffer()` / `.text()` / + `.json()` on a large body puts the whole payload in the isolate heap — + for a DO *and* for a plain Worker — and is the most common way to hit + the 128 MB wall. +- **True streaming** (`put(key, request.body)`, `uploadPart(n, request.body)`, + `response.body.pipeThrough(...)`) keeps heap use roughly constant + regardless of object size. The data passes *through* the isolate's I/O + layer, not *into* its memory. +- **But a DO is the wrong bulk data plane even when streaming**, for two + reasons a plain Worker doesn't have: + 1. *Serialization.* One object = one thread. A fat stream routed + through a per-entity DO occupies that object's single execution + context for the whole transfer; other requests to the same object + interleave only at `await` points and compete for the same isolate. + 2. *Duration billing.* DO compute is billed on **wall-clock duration** + while the object is active (see §3.8), so a slow 500 MB upload + trickling through a DO bills DO duration for the entire transfer. + A plain Worker bills CPU time (I/O wait is not CPU), and Workers + have "no charge or limit for duration" on the Standard model. + Source: https://developers.cloudflare.com/workers/platform/pricing/ + +### 1.5 So what *is* the DO's role in an upload/blob architecture? + +The pattern that falls out of the docs (and the Rules guide's own layering +table) is: **DO as coordinator, R2 as blob store, D1/KV as index.** + +The (small, cheap) control plane goes through the DO; the (large) data +plane does not: + +- **Authorize & mint**: the DO validates "may this user write this key?" + under strong consistency, then returns a presigned PUT URL (or a + multipart `uploadId` + per-part instructions) so bytes flow + client → R2 directly. +- **Register metadata**: on completion the client (or an R2 event/queue + consumer) calls back; the DO records the object's key, size, hash, + owner, and state machine status (`pending → stored → processed`) in its + SQLite storage — a few hundred bytes per artifact. +- **Order operations**: because all calls for one entity serialize through + one object, "the latest version wins", quota checks, and + check-then-write sequences are race-free without locks. +- **Fan out**: the DO pushes "new artifact available" to connected + WebSocket subscribers (hibernatable WebSockets, §5.2) and schedules + follow-up work (thumbnails, virus scan, expiry) via its alarm (§5.3). +- **Enforce invariants a bucket can't**: per-user byte quotas, rate + limits, single-writer-per-document semantics, "only one export job per + tenant at a time". + +--- + +## 2. Core model facts + +All from official sources unless marked. + +1. **One ID → at most one live instance, globally.** "Durable Objects are + defined by a JavaScript class and an ID. There is only ever one instance + of a Durable Object with a given ID running anywhere in the world. All + Workers making subrequests for the Durable Object with that ID are + routed to the same instance." — Cloudflare blog (official): + https://blog.cloudflare.com/durable-objects-ga/ + The Rules guide states the same as its opening premise: "Each Durable + Object is a single-threaded, globally-unique instance with its own + persistent storage." +2. **Single-threaded actor semantics.** Events (requests, RPC calls, + WebSocket messages, alarms) for one object are processed one at a time; + synchronous JavaScript never runs concurrently with itself inside an + object. Interleaving can only happen at `await` points, and the + runtime's input/output gates (§5.4) constrain even that. This removes + lock-based reasoning *within* an object — and caps its throughput. +3. **Throughput ceiling per object.** Official Rules guide: a single DO + handles roughly **500–1,000 requests/second** depending on work per + request (~1,000 simple pass-through, ~500–750 with JSON/validation, + ~200–500 with transformation/storage writes). Design must shard before + this matters. +4. **Co-located storage.** Each object has private storage physically + attached to the object's execution location — SQLite (recommended) or + legacy key-value. Storage calls are local and synchronous-feeling + (the SQL API `ctx.storage.sql.exec()` is literally synchronous), which + is why read-modify-write on every request is affordable. + SQLite storage per object: **10 GB** (GA'd 2025-04-07; official + changelog: https://developers.cloudflare.com/changelog/post/2025-04-07-sqlite-in-durable-objects-ga/). +5. **Placement: created near the first request; sticky thereafter.** + Official Rules guide: "By default, a Durable Object is created near the + location of the first request it receives." You can pass a + `locationHint` (e.g. `wnam`, `weur`, `enam`) on `namespace.get(id, { locationHint })`, + but "location hints are suggestions, not guarantees." + Because compute is co-located with storage, an object's location is + effectively fixed once created — there is no live migration of a hot + object to follow its users. [community detail: jurisdictions + (`namespace.jurisdiction("eu" | "us" | "fedramp")`) are the hard + version of this — a separate sub-namespace whose objects *only* run + and store data inside the jurisdiction, used for data residency; + summarized in https://www.aicassindra.com/blogs/cloud/cloudflare_durable_objects.html + — I did not open the dedicated Data Location doc page, so treat the + exact jurisdiction list as UNVERIFIED beyond that summary.] +6. **In-memory state is a cache, never the truth.** Class properties live + only while the object is in memory. The object is evicted when idle, + on crashes/uncaught exceptions, on deploys and runtime updates. + Official in-memory-state doc: "Variables in a Durable Object will + maintain state as long as your Durable Object is not evicted from + memory," and warns that *global* variables are actively dangerous + because multiple object instances can share one isolate's globals. + Sources: https://developers.cloudflare.com/durable-objects/examples/durable-object-in-memory-state/index.md + and Rules guide ("In-memory state is **not preserved** if the Durable + Object is evicted from memory due to inactivity, or if it crashes from + an uncaught exception. Always persist important state to SQLite + storage."). +7. **No shutdown hooks, by design.** Rules guide: "Durable Objects may + shut down at any time due to deployments, inactivity, or runtime + decisions… Shutdown hooks or lifecycle callbacks that run before + shutdown are not provided." Correct code writes state incrementally + ("write progress as you go"), it does not flush on exit. +8. **Virtual existence.** Objects are never explicitly created or + destroyed by user code: you derive an ID (`idFromName`, `newUniqueId`, + `idFromString`) and the platform activates the object on first use and + evicts it when idle; an object with no stored data is automatically + cleaned up. Creating a stub does **not** wake the object — only + calling a method on the stub does (Rules guide). + [community: this is the classic "virtual actor" model — a good + explanation by a Cloudflare engineer: + http://www.lambrospetrou.com/articles/durable-objects-are-virtual-objects/] + +--- + +## 3. Pitfalls (sourced) + +### 3.1 The hot object / global singleton +The Rules guide's headline anti-pattern: one DO for everything (a global +counter, a **global rate limiter**, one chat room for all rooms) funnels +all traffic through one single-threaded instance. The guide calls out +global rate limiting by name: identify natural coordination boundaries +(per user, per room, per document) instead. A hot object degrades into +queueing, then errors carrying `.overloaded` / `.retryable` properties +that callers are expected to handle with backoff (Rules guide, Error +handling section). Fix is always sharding: more, smaller objects. + +### 3.2 `blockConcurrencyWhile()` misuse +It "guarantees that no other events are processed until the provided +callback completes, even if the callback performs asynchronous I/O" +(Rules guide). Legitimate use: one-time initialization/migrations in the +constructor. Anti-pattern: wrapping per-request work — at ~5 ms per call +it caps the object at ~200 requests/second. Prefer input/output gates, +write coalescing, or `transaction()` for atomicity during request +handling. [community: the callback also has a ~30-second timeout after +which the object is reset, so never wrap slow network calls in it — +https://www.aicassindra.com/blogs/cloud/cloudflare_durable_objects.html] + +### 3.3 Assuming single-threaded means race-free across `await`s +Input gates protect you *during storage operations*. They open during +non-storage I/O. The Rules guide's own example is directly relevant to +R2-centric designs: read item → `await fetch(...)` (or write to R2) → +write item back is a race, because another request can run during the +external call and process the same item. Use check-and-set / version +numbers (optimistic locking) around any read-modify-write that spans +non-storage I/O. + +### 3.4 Write coalescing breaks if you `await` between writes +Synchronous, un-awaited storage writes are batched into one implicit +atomic transaction. Interleaving `await`s on KV-style `get`/`put` calls +breaks coalescing: the guide's broken-transfer example shows a debit +committing before the credit, leaving inconsistent state on failure. +With the SQL API, keep multi-write sequences synchronous, or use an +explicit transaction. + +### 3.5 Non-hibernating WebSockets burn duration — the classic cost surprise +Official pricing doc, verbatim in substance: "Calling `accept()` on a +WebSocket in an Object will incur duration charges for the entire time +the WebSocket is connected. It is recommended to use the WebSocket +Hibernation API to avoid incurring duration charges once all event +handlers finish running." Duration is billed in **wall-clock time** for +as long as the object is active and not hibernation-eligible — so the +legacy pattern of `ws.accept()` + keeping sockets in a JS array bills +you for every idle hour of every connected client. The Hibernation API +(`ctx.acceptWebSocket()`, `webSocketMessage`/`webSocketClose`/ +`webSocketError` handlers, `ctx.getWebSockets()`) lets the object be +evicted from memory while connections stay open at the edge; "Durable +Objects that are idle and eligible for hibernation are not billed for +duration, even before the runtime has hibernated them." +Sources: https://developers.cloudflare.com/workers/platform/pricing/ , +Rules guide (WebSockets section). +[community: a Cloudflare engineer walks through debugging exactly this +distinction — https://thomasgauvin.com/writing/how-cloudflare-durable-objects-websocket-hibernation-works/] + +### 3.6 Holding the object open: `waitUntil`, long handlers, open requests +Anything that keeps an event in flight keeps the object "active" and +billing duration: slow external calls inside handlers, `ctx.waitUntil()` +promises doing slow work, long-lived response streams. Community +gotcha compilations (summarizing the docs) put it bluntly: for deferred +work prefer `storage.setAlarm()` (wakes the object later, briefly) or a +Queue over `waitUntil()` on a slow call [community: +https://deepwiki.com/dmmulroy/cloudflare-skill/6.4-durable-objects-gotchas]. +Also: DOs remain active while "a request, RPC call, response stream, +WebSocket, or pending I/O is in flight" (official Workers limits page, +https://developers.cloudflare.com/workers/platform/limits/). + +### 3.7 In-memory state assumptions +Covered in §2.6–2.7: fields vanish on eviction/crash/hibernation wake; +constructors re-run on every activation, so expensive constructors tax +every cold wake; per-connection state kept in JS variables is lost +across hibernation — use `serializeAttachment()` (survives hibernation; +per-attachment size is small — 2 KB limit is commonly cited [community/ +UNVERIFIED against a doc page I opened]). The Rules guide's rule: +**persist first, cache second** — write storage, then update/invalidate +the in-memory copy. + +### 3.8 Cost surprises (beyond WebSockets) +From the official pricing page (Workers Paid): +- **Duration**: 400,000 GB-s/month included, then $12.50 per million + GB-s — billed on the full 128 MB allocation per object regardless of + actual usage, and rounded *up* to the next billable unit. +- **Requests**: 1M/month included, then $0.15/M. "Requests" includes HTTP + requests, **each RPC method call** (one stub call = one RPC session = + one billed request), **alarm invocations**, and incoming WebSocket + messages at a **20:1 ratio** (100 incoming messages bill as 5 + requests; outgoing messages and protocol pings are free). +- **SQLite rows**: reads are nearly free (25 billion/month included, + then $0.001/M) but **writes are 1,000× that** (50M/month included, + then $1.00/M). Every `setAlarm()` is billed as one row written; + deletes count as rows written; **KV-style `get/put/delete/list` on a + SQLite-backed object are billed as hidden SQLite rows**; index + maintenance adds row writes per indexed column [the index point is + stated on the official D1 section of the same pricing page and in the + community analysis at https://bex.co/blog/2026/08/22/cloudflare-zero-egress-durable-objects-storage-bill-hetzner]. + A chatty object doing a storage write per WebSocket message is the + canonical way to discover this — batch writes. +- **Stored data**: 5 GB-month included, then $0.20/GB-month (SQLite + backend). Legacy KV-backed classes (Paid only): 1M read units + included then $0.20/M, 1M write/delete units then $1.00/M, 1 GB stored + included then $0.20/GB-month; a request unit is 4 KB. +- Free plan: DOs limited to SQLite-backed classes; 100K requests/day and + 13,000 GB-s/day included. +All from https://developers.cloudflare.com/workers/platform/pricing/ + +### 3.9 Hard limits that bite +- **128 MB per isolate** (shared between co-located objects of the same + class + Worker code) — §1.4. Exceeding it resets objects; the reset + victim may not be the memory hog [community: Polylane write-up above]. +- **10 GB SQLite storage per object** (official changelog, §2.4) — a hard + cap; an entity that outgrows it must be split or spill to R2/D1. + KV-style values on SQLite-backed objects are capped at 2 MB per + key/value; SQL statements at 100 KB and tables at 100 columns + [community-compiled limits table, consistent with the docs: + https://deepwiki.com/dmmulroy/cloudflare-skill/6.4-durable-objects-gotchas + — I did not open the dedicated DO limits page directly, so treat these + three numbers as UNVERIFIED against primary docs in this pass]. +- **CPU time**: DO invocations live under the Workers CPU limits — + Paid default 30 s, configurable to 5 min max per invocation + (official: https://developers.cloudflare.com/workers/platform/limits/). + Alarm invocations have a 15-minute duration limit (same page). +- **WebSocket message size**: max 32 MiB (raised from 1 MiB on + 2025-10-25; official DO release notes: + https://developers.Cloudflare.com/durable-objects/release-notes/). +- **One alarm per object at a time**: `setAlarm()` replaces any existing + alarm — multiple logical timers must be implemented as a stored + event queue with the single alarm set to the earliest deadline + [pattern per Rules guide alarms section + community gotchas]. + +### 3.10 Placement latency for far-away users +The object is born near its *first* requester and stays there (§2.5). +Every subsequent request from anywhere on Earth pays a round trip to +that one location. A room created by a user in Frankfurt serves Sydney +users at Frankfurt latency forever. Mitigations are all design-time: +choose object granularity with locality (per-team/per-match rather than +per-global-entity), pass `locationHint` when you know better than the +first request, and keep far-flung read paths on KV/D1/R2 (globally +replicated) with the DO only on the write/coordinate path. + +### 3.11 Class lifecycle, migrations, and versioning pain +- A class's **storage backend is chosen at creation** (`new_sqlite_classes` + vs legacy `new_classes` in migrations) and cannot be flipped in place; + picking `new_classes` for a new class is a common self-own [community + + Rules guide's insistence on SQLite for new classes]. Cloudflare says + a KV→SQLite migration path will be offered "in the future" (official + changelog, 2025-04-07). +- Class renames/deletes/transfers are deploy-time operations (migrations + array, or the newer declarative `exports` field — Rules guide shows + `state: "renamed"` / `state: "deleted"` entries). Deleting a class + **destroys all its objects' data**; migration tags must be unique and + cannot be rolled back [community gotchas table, consistent with docs: + https://deepwiki.com/dmmulroy/cloudflare-skill/6.4-durable-objects-gotchas]. +- **Data-schema** migrations are *your* problem and run lazily, per + object, in the constructor under `blockConcurrencyWhile()` (Rules + guide's `_sql_schema_migrations` pattern) — meaning old-schema and + new-schema objects coexist across deploys, and a bad migration only + detonates when that particular object next wakes. +- Code deploys replace the code for *all* objects of a class at once; + in-flight objects are restarted under the new code (another reason + in-memory state is not a contract). + +### 3.12 Testing pain points +Officially, testing is now first-class: `@cloudflare/vitest-plugin` / +`@cloudflare/vitest-pool-workers` run DOs in the real runtime with +isolated storage, `runInDurableObject(stub, (instance, state) => …)` for +arranging/asserting internals, and `runDurableObjectAlarm(stub)` to fire +alarms immediately (Rules guide, Testing section). The remaining pain is +intrinsic rather than tooling [assessment, informed by the sources]: +alarms/hibernation/eviction are time- and runtime-driven, so tests can +trigger them but production timing (when exactly eviction happens, how +long a non-hibernating object lingers) is not deterministic; placement +and cross-region latency can't be reproduced locally at all; and +concurrency bugs that depend on gate interleavings (§3.3) only appear +under realistic concurrent load, not unit tests. + +--- + +## 4. Advantages vs the alternatives + +| | Durable Objects | Workers KV | D1 | Plain Workers | External Redis/Postgres | +| --- | --- | --- | --- | --- | --- | +| Consistency | **Strong**, per object; serialized execution + transactional storage | Eventual (global propagation, typically seconds–~60 s) | Strong at the single primary; read replicas are eventually consistent | None (stateless) | Depends (Redis: per-node; Postgres: strong) | +| Coordination | **Native** — single-writer actor per entity; no locks, no CAS loops | None — read-modify-write races are real | SQL transactions, but contended global hot rows serialize at one primary | None | Redis locks/Lua, Postgres advisory locks — you build and operate it | +| Connections | **Hibernatable WebSockets owned per object**; fan-out is a loop over `ctx.getWebSockets()` | n/a | n/a | Can proxy WebSockets but holds no per-room state | You run the socket servers | +| Scheduling | **Per-entity alarms** (one timer per object, wakes the object) | n/a | n/a | Cron Triggers are per-Worker, global schedule | External cron/queues | +| Latency shape | ~0 ms to own storage (co-located); possibly a cross-planet trip to *reach* the object | ~0 ms reads at every edge (cached) | Reads near user with replication; writes travel to the primary's location | Runs at the nearest edge, always | A network hop (mitigated by Hyperdrive pooling/caching) from every Worker | +| Scale model | Scales by adding objects (IDs); each object caps at ~500–1,000 req/s | Effectively unlimited reads; writes ~1/s per key guidance [UNVERIFIED in this pass] | One database: 10 GB cap, single-writer throughput | Effectively unlimited | Whatever you provision | +| Ops burden | Zero servers; pay requests + duration + rows | Zero | Zero | Zero | Yours (or a vendor's) | + +Narrative version: + +- **vs KV**: KV is a globally replicated, eventually consistent cache — + superb for read-mostly config/session data at every edge, wrong for + anything needing atomic check-and-set. The canonical failure: a rate + limiter on KV where two concurrent requests both read "99" and both + pass [community book chapter making this exact point: + https://architectingoncloudflare.com/chapter-12/]. If the operation is + "read state, decide, write state" it belongs in a DO (or D1), not KV. +- **vs D1**: D1 is one SQLite database (itself built on DO technology) + with a single primary location — great for cross-entity queries, + joins, and read models; its write path funnels to one place, and one + hot row is everyone's problem. DOs invert this: no cross-object + queries at all, but millions of independent single-writer databases + that never contend with each other. The standard pairing is DOs as the + write/coordination tier and D1 as the queryable projection/index + (see §5.6). +- **vs plain Workers**: Workers are stateless and run at the nearest + edge — strictly better for anything that doesn't need shared state, + identity, or connections. The Rules guide's framing: "Use Durable + Objects for stateful coordination, not stateless request handling"; + front them with a Worker that does auth/validation/routing. +- **vs external Redis/Postgres**: a DO gives you the Redis-list/lock + class of primitives and the Postgres-transaction class of guarantees + per entity, with no connection management from Workers (a real pain + point that Hyperdrive exists to soften), no servers, and scale-to-zero + billing. What you give up: cross-entity transactions and queries, + mature tooling/observability, big-memory compute, and an exit ramp — + DO storage APIs are Cloudflare-proprietary, so the state layer does + not port. + +The advantages that have no real substitute elsewhere on the platform: +strong consistency + transactions *per entity* without a database round +trip; WebSocket fan-out where the connection owner *is* the state owner; +per-entity alarms (a million independent timers with zero polling); and +the actor-model fit — code reads like a single-threaded class, because +it is one. + +--- + +## 5. Best practices and common techniques + +Mostly from the official Rules guide +(https://developers.cloudflare.com/durable-objects/best-practices/rules-of-durable-objects/), +published 2025-12-15, plus marked community sources. + +### 5.1 One DO per entity — the "atom of coordination" +"Create one Durable Object per logical unit that needs coordination: a +chat room, a game session, a document, a user's data, or a tenant's +workspace." Route deterministically with `getByName()` / `idFromName()` +so the same entity always lands on the same object; reserve +`newUniqueId()` for when you genuinely need a fresh random instance and +will store the ID mapping elsewhere (D1/KV). Parent/child structures +(one index DO per tenant, one DO per match under it) keep list/query +operations off the hot objects. Compute needed shard count up front: +total req/s ÷ ~500–1,000 per object. + +### 5.2 Hibernatable WebSockets, always +Use `ctx.acceptWebSocket()` + `webSocketMessage/Close/Error` handlers +instead of the legacy `ws.accept()` pattern (§3.5). Store per-connection +metadata (user ID, session info) with `serializeAttachment()` so it +survives hibernation; enumerate sockets with `ctx.getWebSockets()` for +broadcasts instead of keeping a JS array (which hibernation erases). +On compatibility dates ≥ 2026-04-07 the runtime auto-replies to Close +frames (`web_socket_auto_reply_to_close`); on older dates you must call +`ws.close()` in `webSocketClose` or clients see 1006 errors (Rules +guide). Incoming messages bill at 20:1 as requests, outgoing are free — +chatty *inbound* protocols are the cost driver, so batch client updates +where the protocol allows. + +### 5.3 Alarms instead of polling +One alarm per object (`ctx.storage.setAlarm(timestamp)`, ms precision; +re-set it inside `alarm()` for recurrence — alarms don't repeat on +their own). Canonical uses: session/game expiry, subscription renewal, +deferred flush of buffered writes, cleanup/TTL of the object's own data, +retry-with-backoff workflows. Rules: make `alarm()` **idempotent** +(alarms can fire more than once), inspect `alarmInfo.retryCount` +(alarms retry on throw; the guide's pattern re-schedules manually near +the retry limit rather than losing the work), and "only schedule alarms +when there is work to do" — an alarm per object per few seconds across +a million objects is a million billable wake-ups (each `setAlarm` is +also a billed row write, §3.8). For multiple logical timers, keep a +sorted events table in SQLite and set the single alarm to the earliest. + +### 5.4 Let the gates work for you; keep write paths synchronous +- Input gates: no new event is delivered while your synchronous code + runs, and storage awaits hold the gate — so a read-modify-write done + entirely against storage is race-free *without* locks. +- Output gates: responses and outgoing fetches are held until pending + storage writes commit — clients can never observe success for data + that wasn't persisted. This is why `sql.exec()` writes don't need to + be awaited for correctness. +- Write coalescing: a run of synchronous storage writes commits as one + implicit atomic transaction (§3.4). Structure hot methods as: + load → decide → write synchronously → return. +- `blockConcurrencyWhile()`: constructor init/migrations only (§3.2). +- `transaction()` / `transactionSync()`: for explicit multi-step + atomicity in request handling without freezing the object. + +### 5.5 Storage hygiene +- New classes: SQLite backend (`new_sqlite_classes`), SQL API, indexes + on filtered columns, schema versioned via a `_sql_schema_migrations` + table applied in the constructor (all Rules guide patterns). +- **Batch writes**: coalesce, use transactions, or buffer high-frequency + updates (game positions, metrics) in memory and flush on an interval + or via alarm — rows written are the expensive meter (§3.8). +- **Idempotency keys**: for any operation a client may retry (payments, + uploads-complete callbacks, webhook deliveries), accept a + client-supplied ID, store it in SQLite in the same transaction as the + effect, and return the stored result on duplicates. Single-threaded + execution makes the check-and-set trivially correct — this is one of + the highest-value DO patterns [technique; illustrated in community + write-ups, e.g. dedupe-by-event-ID in + https://dev.to/instawebhook/routing-webhooks-through-cloudflare-workers-kv-and-durable-objects-building-a-globally-distributed-1gje]. +- Cache in memory *after* persisting; treat every wake as a cold start; + keep constructors cheap (schema DDL with `IF NOT EXISTS` only). +- `deleteAll()` to fully retire an object (data + alarm; compat-date + nuances in the Rules guide). + +### 5.6 The reference architecture: DO coordinates, R2 stores blobs, D1 indexes +For artifact/file-shaped systems (the §1.5 pattern, generalized): + +``` +Client ──control──▶ Worker ──▶ DO (per user/room/doc) + │ ├─ auth, quota, ordering, state machine (SQLite) + │ ├─ mints presigned URL / multipart session + │ └─ records metadata + fans out over WebSockets + └──────data (presigned/multipart direct)──────▶ R2 (blobs) +Worker/Queue consumer ──▶ D1 (cross-entity index, search, admin queries) +``` + +- Small, hot, consistency-critical state → DO SQLite. +- Bytes → R2, addressed by keys the DO minted and recorded. +- Anything you need to `SELECT … WHERE` across entities → projected + into D1 (synchronously for small writes, or via Queues/alarms for + fan-out), because cross-DO queries don't exist. +- Reads that are global and stale-tolerant → KV or R2 public/custom + domain delivery, bypassing the DO entirely. + +### 5.7 Canonical DO roles (with the sharding caveat applied) +- **Chat room / live presence** — one DO per room; hibernatable + WebSockets; history in SQLite; attachments in R2. +- **Multiplayer game session / collaborative document** — one DO per + session/document; single-threaded authority replaces OT/CRDT server + coordination for the live state; alarm as the game tick/timeout. +- **Rate limiter / token bucket** — one DO **per entity being limited** + (per user, per API key, per tenant). Atomic check-and-increment in + synchronous code against storage. A *global* limiter DO is the Rules + guide's named anti-pattern (§3.1) — shard by entity or use + approximate counting in the Worker with periodic DO reconciliation. +- **Leader election / single-flight** — one DO per lock name: the + platform's guarantee that only one instance exists *is* the election; + the holder renews via alarm, contenders ask the DO. Dedup/single-flight + for webhook processing and cache-stampede protection are the same + shape [pattern assessment; the uniqueness guarantee it rests on is + official, §2.1]. +- **Per-user/per-tenant anything** — inbox, cart, game state, agent + session: the Agents SDK itself is built as DO-per-agent for exactly + these properties. +- **Coordinator for heavy compute** — the DO holds session state and + drives a Container or Browser Run session (Cloudflare's own Browser + Run DO tutorial is this pattern), keeping the heavy runtime outside + the isolate while ordering stays in the DO. + +### 5.8 RPC over `fetch()` for DO APIs +Official guidance (Rules guide): for projects with compatibility date +≥ 2024-04-03, define public methods on the DO class and call them on the +stub (`await stub.bookSeat(...)`) instead of implementing a `fetch()` +handler and hand-parsing Requests. You get TypeScript types end-to-end, +structured-cloneable arguments/returns, and exceptions that propagate. +Billing note: **every stub method call is one billed request**; methods +that return an `RpcTarget` stub let subsequent calls ride the same RPC +session unbilled (official pricing footnotes). Keep `fetch()` for the +cases that genuinely are HTTP: WebSocket upgrades (which need the +Request/Response pair) and proxying/streaming a request body through to +somewhere else (e.g. §1.3a) — a body stream is not an RPC-shaped value. +[UNVERIFIED: whether RPC supports passing ReadableStream arguments — +not stated in the pages opened here; design as if it does not.] + +### 5.9 Errors and overload are part of the API +Stub calls can fail with errors exposing `.retryable` and `.overloaded` +(Rules guide). Production callers should retry retryable errors with +exponential backoff + jitter and treat `overloaded` as the signal that +an entity has outgrown one object (time to sub-shard it), not as a +transient blip. + +--- + +## Appendix: numbers used above, with provenance + +| Fact | Value | Source | +| --- | --- | --- | +| Memory limit | 128 MB per isolate, all plans | Official: workers/platform/limits | +| DO duration billing basis | Wall-clock while active & not hibernation-eligible; billed as full 128 MB allocation | Official: workers/platform/pricing | +| DO requests (Paid) | 1M/mo incl., +$0.15/M; incl. HTTP, per-RPC-call, alarm invocations, WS msgs at 20:1 | Official: workers/platform/pricing | +| DO duration (Paid) | 400,000 GB-s/mo incl., +$12.50/M GB-s | Official: workers/platform/pricing | +| SQLite rows read (Paid) | 25B/mo incl., +$0.001/M | Official: workers/platform/pricing | +| SQLite rows written (Paid) | 50M/mo incl., +$1.00/M; setAlarm = 1 write; deletes = writes | Official: workers/platform/pricing | +| SQLite stored data (Paid) | 5 GB-month incl., +$0.20/GB-month | Official: workers/platform/pricing | +| SQLite storage per object | 10 GB | Official: changelog 2025-04-07 (SQLite GA) | +| Per-object throughput | ~500–1,000 req/s | Official: Rules of Durable Objects | +| WebSocket max message size | 32 MiB (since 2025-10-25) | Official: DO release notes | +| CPU per invocation (Paid) | 30 s default, 5 min max; alarm duration limit 15 min | Official: workers/platform/limits | +| KV value cap on SQLite-backed DOs; SQL statement/column caps | 2 MB; 100 KB; 100 cols | [community compilation — UNVERIFIED against primary limits page in this pass] | +| DO classes per account | 100 (Free) / 500 (Paid) | [community compilation — UNVERIFIED in this pass] | +| blockConcurrencyWhile callback timeout | ~30 s, then object resets | [community — aicassindra deep-dive] | +| WebSocket attachment size cap | 2 KB commonly cited | [community — UNVERIFIED in this pass] | diff --git a/doc/2026-11-24T02-42-57Z_research_cloudflare/docs/research-free-tiers.md b/doc/2026-11-24T02-42-57Z_research_cloudflare/docs/research-free-tiers.md new file mode 100644 index 000000000..692fc7389 --- /dev/null +++ b/doc/2026-11-24T02-42-57Z_research_cloudflare/docs/research-free-tiers.md @@ -0,0 +1,131 @@ +# Cloudflare — Services With a Free Tier: Limits, Type, and When Charges Start + +**Research date:** 2026-10-20 +**Scope:** Every Cloudflare service with a genuine free offer, across the website plans, Zero Trust, and the developer platform — not just Workers. +**Method:** Official Cloudflare sources first (`developers.cloudflare.com` pricing/limits pages and `cloudflare.com/plans`). Every row carries its source URL. Where only a secondary source could be found, or official pages conflict, the row is flagged **UNVERIFIED** — do not budget from an UNVERIFIED row without re-checking the official page. +**Prices:** USD, as published on the cited page on the research date. Nothing here is invented; a missing price means the official page did not publish one. + +## How to read the "Type" column — the trial-vs-free distinction + +| Code | Meaning | +|---|---| +| **(a) Perpetual free tier** | A standalone $0 plan / allowance that renews indefinitely (daily or monthly reset). No payment, no expiry. On most Workers-platform free tiers, exceeding the limit is a **hard stop** (operations fail until reset), not a bill. | +| **(b) Free allowance inside a paid plan** | $0 only because you already pay for a plan (usually Workers Paid, $5/mo minimum, or a Pro/Business zone plan). There is **no way to use the free amount without the paid plan**. Overage is metered automatically — this is where surprise bills come from. | +| **(c) Time-limited TRIAL** | Free only for a fixed window, then it charges or stops. **Almost nothing in Cloudflare's catalogue is actually a (c).** See §4 — the common confusions (Stream on Pro/Business, Email Sending, Containers) are (b), not trials. | + +> **Headline finding:** Cloudflare essentially does not do time-limited trials on self-serve products. Its "free" is either (a) perpetual with a hard cap, or (b) an included allowance inside a $5+ paid plan with metered overage. The risk model is therefore not "trial expires" — it is "hard stop at midnight UTC" on (a), and "unbounded metered overage" on (b). + +--- + +## 1. Website / zone plans and network services (perpetual free — type a, unless noted) + +| Service | Free tier limits (exact) | Type | When charges start (threshold) | First paid price / overage after free | Source | +|---|---|---|---|---|---| +| **Free zone plan — DNS, CDN, DDoS, Universal SSL, Web Analytics (bundle)** | $0/mo per zone. Fast DNS; global CDN (200+ locations on plans page); unmetered DDoS mitigation; free automated (Universal) SSL certificates; Web Analytics included; up to 100K Workers requests; up to 65 Cloudflare Rules total. Pro is $20/mo billed annually / $25/mo billed monthly; Business $200/mo annual / $250/mo monthly. | (a) Perpetual | Never for the bundle itself — you only pay if you voluntarily upgrade the zone or enable a paid add-on. CDN bandwidth is not metered on any plan. | Pro: $20/mo (annual) / $25/mo (monthly) per zone | https://www.cloudflare.com/lp/pg-all-plans-ssl/ | +| **Authoritative DNS** | Included in Free zone plan (above); no per-query price published on Free. Record/rule counts are bounded by the 65-Rules figure on the plans page. | (a) Perpetual | No DNS overage charge on self-serve plans. | n/a — upgrade is the zone plan (Pro $20/$25) | https://www.cloudflare.com/lp/pg-all-plans-ssl/ | +| **CDN / caching** | Unmetered bandwidth, all plans including Free. Note the Self-Serve terms restrict using Free/Pro/Business primarily to serve video / large non-HTML files — enforcement is discretionary, no published GB threshold. **UNVERIFIED threshold** (no official number exists). | (a) Perpetual | No per-GB charge at any self-serve tier. | n/a | https://www.cloudflare.com/lp/pg-all-plans-ssl/ | +| **DDoS protection (L3/4/7)** | Unmetered, always on, no configuration needed; included in Free. | (a) Perpetual | Never metered. | n/a | https://developers.cloudflare.com/waf/feature-interoperability/ | +| **Universal SSL / free TLS** | Free automated certificates covering apex + first-level subdomains; automatic renewal. Multi-level subdomains / custom cert upload are **not** Free (Advanced Certificate Manager / Business). | (a) Perpetual | Only if you buy ACM or upgrade. | Advanced Certificate Manager: starting at $10/mo | https://www.cloudflare.com/plans/application-services/ | +| **WAF — Free Managed Ruleset + custom rules** | Free Managed Ruleset included; **5 custom WAF rules** and **1 rate-limiting rule** on Free (rate-limit rule: 10-second window / 10-second block, IP-counted — **UNVERIFIED on official page**, from a detailed secondary audit of the Free plan). Plans page gives the aggregate "up to 65 Cloudflare Rules" for Free, 155 for Pro. | (a) Perpetual | 6th custom rule simply cannot be created on Free (configuration-time refusal, not a bill). | Pro: $20/mo annual / $25/mo monthly, incl. enhanced WAF + 20 custom WAF rules (plans page) | https://www.cloudflare.com/lp/pg-all-plans-ssl/ ; secondary for 5-rule detail: https://dhodrajsundaram.substack.com/p/cloudflare-free-tier-limits | +| **Bot Fight Mode** | Free, on Free plans: simple on/off toggle, challenges traffic matching known-bot patterns, protects entire domain, **cannot** be customised or skipped via custom rules. (Super Bot Fight Mode is Pro/Business/Enterprise only; full Bot Management with bot scores 1–99 is an Enterprise add-on — neither is free.) | (a) Perpetual | Never — no paid Bot Fight Mode tier. Granularity requires plan upgrade / Enterprise Bot Management (custom price, not published). | Enterprise Bot Management: contact sales (no published price) | https://developers.cloudflare.com/bots/get-started/bot-fight-mode/ ; https://developers.cloudflare.com/bots | +| **API Shield — free aspects only** | On **Free zone plan**: 100 saved endpoints; 5 enabled uploaded schemas; 200 KiB combined size of enabled schemas; rule action `Block` only. Pro: 250 endpoints / 5 schemas / 500 KiB. Business: 500 / 10 / 2 MiB. **Full API Shield subscription itself requires an Enterprise plan** (contact account team) — only the endpoint/schema allowances above exist on Free. | (a) Perpetual (partial feature) | No overage meter on Free — limits are caps. Full product starts at Enterprise. | Enterprise: custom (no published price) | https://developers.cloudflare.com/api-shield/plans/ | +| **Waiting Room** | **NO free tier.** Available only on Business and Enterprise zone plans; Business includes 1 waiting room. | — Not free | From the first room: requires Business. | Business: $200/mo annual / $250/mo monthly per zone | https://www.cloudflare.com/lp/pg-all-plans-ssl/ ; secondary detail: https://www.crowdhandler.com/blog/crowdhandler-vs-cloudflare-waiting-room-which-virtual-queue-solution-is-right-for-you | +| **Turnstile** | **Free, unlimited challenges / verifications.** Free plan: up to 20 widgets; 10 hostnames per widget; all widget types; analytics lookback 7 days max; pre-clearance supported. Works on any site, no Cloudflare proxy required. Enterprise: unlimited widgets, 200 hostnames/widget, 30-day analytics, Ephemeral IDs, remove branding. | (a) Perpetual | Never for the Free feature set — there is no per-verification charge at any volume on Free. | Enterprise: contact sales (no published price) | https://developers.cloudflare.com/turnstile/plans/ | +| **Web Analytics** | Free (also usable standalone). Site limits: 10 sites **not** proxied through Cloudflare; **no limit** for proxied sites. Rules: Free 0, Pro 5, Business 20, Enterprise 100. | (a) Perpetual | No charge — limits are site/rule caps, not meters. | n/a (higher rule limits come with zone plan upgrade) | https://developers.cloudflare.com/web-analytics/limits/ | +| **Zone Analytics / HTTP Analytics** | Included with the Free zone plan (traffic, bandwidth, mitigated-attack reporting). No separate price published. | (a) Perpetual | Never metered separately. | n/a | https://www.cloudflare.com/lp/pg-all-plans-ssl/ | +| **Zaraz (tag manager)** | **1,000,000 Zaraz Events / month free, every account, all tiers.** All Zaraz features/tools available on all accounts (page view or `zaraz.track` = 1 event). If Zaraz Paid is **not** enabled: email warnings at 50% / 80% / 90%, and Zaraz is **disabled until next billing cycle** past 1M (hard stop, no bill). | (a) Perpetual | Event 1,000,001 — only billed if you explicitly enable Zaraz Paid. | Zaraz Paid: $5/mo per additional 1,000,000 events | https://developers.cloudflare.com/zaraz/pricing-info/ | +| **DMARC Management** | Free for every Cloudflare customer (GA 2026-06-16, per Cloudflare blog: "free for every Cloudflare customer", available "with no additional configuration or cost"). No published report-volume cap. | (a) Perpetual | No paid DMARC Management tier published. | n/a | https://blog.cloudflare.com/dmarc-management-ga/ | +| **Registrar** | **NOT a free tier — at-cost pass-through, and that distinction matters.** Cloudflare charges exactly the registry wholesale price + ICANN fee, **$0 markup**, same price at renewal, free WHOIS redaction / DNSSEC. Plans page: "Starting at $7.85" (cheapest TLDs). You still pay the registry cost from day one — there is no free domain and no intro discount that later jumps. Domains must use Cloudflare nameservers. | At-cost (not free, not a trial) | Charged at registration/transfer, at cost. Transfers include +1 year at cost for most TLDs (.uk/.nz transfers: no fee, no added year). | Registry price per TLD (e.g. .com is registry-set; Cloudflare adds $0) | https://www.cloudflare.com/plans/application-services/ ; https://developers.cloudflare.com/registrar/faq/ ; https://www.cloudflare.com/en-in/learning/dns/what-is-cloudflare-registrar/ | +| **1.1.1.1 DNS resolver + consumer WARP** | Free consumer app / resolver, no account, no trial clock (per Cloudflare blog: try the free consumer WARP client 1.1.1.1 today; the free Zero Trust offering is the separate teams product below). Optional paid upgrade is WARP+ / WARP+ Unlimited — price **UNVERIFIED** (secondary sources cite ~$4.99/mo; Cloudflare's official page fetched here did not publish it). | (a) Perpetual | Never for base WARP / 1.1.1.1. | WARP+ Unlimited: UNVERIFIED (~$4.99/mo per secondary sources) | https://blog.cloudflare.com/post-quantum-warp/ | +| **Argo Smart Routing (+ Tiered Caching / Smart Shield)** | **NO genuine free tier.** Plans page: "Starting at $5 per month". A secondary billing analysis cites a first-1-GB-included figure — **UNVERIFIED on an official page**; do not rely on it. Argo is usage-priced per GB after the base fee and has no published cap. | — Not free | $5/mo base from activation, plus per-GB transfer. | $5/mo + $0.10/GB (per-GB rate UNVERIFIED on official page; base $5 verified) | https://www.cloudflare.com/plans/application-services/ | +| **Load Balancing** | **NO free tier and NO confirmed free trial.** Plans page: "Starting at $5 per month". Original launch post: $5/mo includes 500,000 DNS queries/month (enough for most sites); additional origins historically +$5/mo each — origin pricing **UNVERIFIED** on a current official page. The trial question: **VERIFIED 2026-10-25 — no trial exists.** Checked against the official plans page, the launch post, current billing docs, and the LB docs index ("Add-on feature"); no official source mentions any trial. The "15-day trial" claim in the 2026-10-20 reference PDF and early summaries was an error. | — Not free (not a trial) | $5/mo from activation. | Starting at $5/mo (500,000 DNS queries included per launch post) | https://www.cloudflare.com/plans/application-services/ ; https://blog.cloudflare.com/introducing-load-balancing-intelligent-failover-with-cloudflare | +| **Cache Reserve** | **NO free tier.** Usage-based on R2-style rates, requires a paid plan. Secondary billing summaries: $0.015/GB-month storage + $4.50/M Class A + $0.36/M Class B — **UNVERIFIED** as a Cache-Reserve-specific official table in this pass. | — Not free | First GB stored, once enabled on a paid plan. | See R2 rates in §3 (UNVERIFIED for Cache Reserve specifically) | https://developers.cloudflare.com/r2/pricing/ | + +--- + +## 2. Zero Trust / Cloudflare One (perpetual free for small teams — type a) + +| Service | Free tier limits (exact) | Type | When charges start (threshold) | First paid price / overage after free | Source | +|---|---|---|---|---|---| +| **Zero Trust Free plan (Access + Gateway + WARP for Teams, bundle)** | **$0 forever, up to 50 users.** Access product page: "Free Plan — $0 forever — Best for teams under 50 users". Secondary detail (**UNVERIFIED** on official page): up to 3 locations for Gateway DNS policies; ~24 hours of log retention; community support only. | (a) Perpetual | User 51, or needing paid features (longer log retention, SLA, support). No metered overage — it is a seat cap. | Pay-as-you-go: **$7 / user / month (paid annually)**, no user limit, 100% uptime SLA, up to 30 days log retention | https://www.cloudflare.com/sase/products/access/ | +| **Access (ZTNA)** | Included in Zero Trust Free (above): customizable access policies, self-hosted / SaaS / non-web (SSH, VNC, RDP) apps, multiple IdPs incl. SAML/OIDC, device-posture checks, clientless access for web apps. Seat limit is the bundle's 50 users. | (a) Perpetual | Seat 51 (via Zero Trust plan). | $7/user/mo (annual) Pay-as-you-go | https://www.cloudflare.com/sase/products/access/ | +| **Tunnel (cloudflared)** | No separate Tunnel charge and no bandwidth meter for the connector itself; it rides the Zero Trust plan, so the practical free ceiling is the Free plan's 50 users. (A "Tunnels for Platforms" tier for >1,000 tunnels/account was reported by secondary sources in Oct 2026 — **UNVERIFIED**, irrelevant at personal scale.) | (a) Perpetual | Only via the Zero Trust seat plan; tunnels themselves are unmetered. | $7/user/mo (annual) if the team outgrows Free | https://www.cloudflare.com/sase/products/access/ | +| **Gateway (DNS/HTTP filtering, SWG)** | Included in Zero Trust Free (50 users). Paid raises location count and log retention (see bundle row). | (a) Perpetual | Seat 51 / paid features. | $7/user/mo (annual) | https://www.cloudflare.com/sase/products/access/ | +| **WARP client for Teams** | Included in Zero Trust Free (50 users); same client family as consumer WARP (§1) but org-managed. | (a) Perpetual | Seat 51. | $7/user/mo (annual) | https://www.cloudflare.com/sase/products/access/ | +| **Browser Isolation, CASB, full DLP, Logpush for Zero Trust** | **Not in Free.** Free DLP is limited to predefined profiles (in AI Gateway: 2 predefined profiles free — see §3). Browser Isolation is a paid add-on on eligible paid plans. Prices not published on the pages fetched — **UNVERIFIED**. | — Not free | From activation on a paid Zero Trust plan. | Custom / add-on (no published price found) | https://developers.cloudflare.com/ai-gateway/reference/pricing/ | + +--- + +## 3. Developer platform (Workers ecosystem) + +**The pattern to internalise:** on **Workers Free**, every limit below is a **hard stop** (daily limits reset 00:00 UTC; monthly R2/Zaraz-style allowances reset monthly) — you cannot be billed. On **Workers Paid ($5/mo account minimum)**, the *same products* switch to large included monthly allowances + metered overage. Moving to Paid is what converts a capped free tier into an unbounded bill. + +| Service | Free tier limits (exact) | Type | When charges start (threshold) | First paid price / overage after free | Source | +|---|---|---|---|---|---| +| **Workers (compute)** | **100,000 requests/day; 10 ms CPU per invocation;** static-asset requests free & unlimited; 128 MB memory. (Limits page via secondary summaries: 100 Workers/account, 50 subrequests/request — plan/pricing page is the source for the request/CPU figures.) | (a) Perpetual | On Free: requests fail past 100k/day (no bill). Paid: past 10M requests/mo or 30M CPU-ms/mo included. | Workers Paid: **$5/mo minimum**; +$0.30 per additional million requests; +$0.02 per additional million CPU-ms; max 5 min CPU/invocation (default 30 s) | https://developers.cloudflare.com/workers/platform/pricing/ | +| **Pages** | **500 builds/month; 1 concurrent build; 20-min build timeout; 100 custom domains/project; 20,000 files/site; 25 MiB max file;** unlimited sites, unlimited static requests & bandwidth. Pages Functions bill as Workers (shared 100k/day Free quota). | (a) Perpetual | Build 501 in a month (build capacity is set by the **zone** plan, not Workers Paid). | Pro zone: $20/mo annual / $25 monthly → 5,000 builds, 5 concurrent. Business: $200/$250 → 20,000 builds, 20 concurrent | https://developers.cloudflare.com/pages/platform/limits/ | +| **Workers Builds** | **3,000 build minutes/month; 1 concurrent build; 20-min timeout** — **UNVERIFIED on an official page in this pass** (from a detailed secondary analysis citing the Workers Builds limits/pricing docs). Distinct from Pages builds (count vs. minutes). | (a) Perpetual (UNVERIFIED) | Past 3,000 min/month, on Paid. | Paid: 6,000 min included, then $0.005 per additional minute; 6 concurrent (UNVERIFIED) | https://omidsaffari.com/blog/is-cloudflare-worker-previews-free | +| **Workers KV** | **100,000 keys read/day; 1,000 keys written/day; 1,000 deleted/day; 1,000 list requests/day; 1 GB stored.** All daily limits reset 00:00 UTC; exceeding any one fails further ops of that type. | (a) Perpetual | On Free: hard fail, no bill. Paid included: 10M reads/mo, 1M writes/mo, 1M deletes/mo, 1M lists/mo, 1 GB. | +$0.50/M reads; +$5.00/M writes, deletes, lists; +$0.50/GB-month stored (all require Workers Paid, $5/mo min) | https://developers.cloudflare.com/workers/platform/pricing/ ; https://developers.cloudflare.com/kv/platform/pricing/ | +| **D1 (serverless SQL)** | **5 million rows read/day; 100,000 rows written/day; 5 GB total storage.** Free limits reset daily 00:00 UTC; past the daily read/write cap, queries fail until reset (enforcement hardened 2026-09-01 per secondary reporting). Per-database size cap on Free (500 MB) is from secondary sources — **UNVERIFIED** here. | (a) Perpetual | On Free: hard fail, no bill. Paid included: first 25 **billion** rows read/mo, first 50M rows written/mo, first 5 GB storage. | +$0.001 per million rows read; +$1.00 per million rows written; +$0.75/GB-month storage (Workers Paid) | https://developers.cloudflare.com/workers/platform/pricing/ | +| **Durable Objects (SQLite-backed)** | **100,000 requests/day; 13,000 GB-seconds duration/day;** SQLite storage: **5M rows read/day, 100,000 rows written/day, 5 GB total SQL storage** (same rates as D1). Free plan can **only** create SQLite-backed objects; key-value backend is Paid-only. Hibernatable idle objects are not billed for duration. | (a) Perpetual | On Free: hard cap, no bill. Paid included: 1M requests/mo, 400,000 GB-s/mo. | +$0.15/M requests; +$12.50 per million GB-s duration; SQL storage +$0.20/GB-month past 5 GB (Workers Paid). KV backend (Paid only): 1M read/write/delete units incl., then $0.20/M reads, $1.00/M writes/deletes, $0.20/GB-month past 1 GB | https://developers.cloudflare.com/workers/platform/pricing/ | +| **R2 (object storage)** | **Per month: 10 GB-month Standard storage; 1M Class A ops; 10M Class B ops; egress free (always, all tiers).** Free tier applies to **Standard storage only** — Infrequent Access gets **no** free allowance (its examples bill from the first GB/op). DeleteObject/DeleteBucket/AbortMultipartUpload are free operations. Super Slurper & Sippy migration tools are free to use (you pay only the R2 ops they make). | (a) Perpetual — **but see note** | ⚠️ Unlike the daily-capped products, R2's monthly allowance sits on an account that can be billed: past 10 GB-month / 1M Class A / 10M Class B, Standard rates apply. Confirm billing behaviour on your account before treating R2 Free as a hard stop. | Storage $0.015/GB-month (Standard), $0.01 (Infrequent Access); Class A $4.50/M (Std) / $9.00/M (IA); Class B $0.36/M (Std) / $0.90/M (IA); IA retrieval $0.01/GB; egress $0 | https://developers.cloudflare.com/r2/pricing/ | +| **Queues** | **10,000 standard operations/day included; 24-hour message retention (non-configurable).** 1 operation = each 64 KB chunk written, read, or deleted — a normal delivered message costs ~3 ops. No egress/bandwidth charges. | (a) Perpetual | On Free: daily cap. Paid included: 1,000,000 ops/month; retention 4 days default, configurable to 14. | +$0.40 per million operations (Workers Paid) | https://developers.cloudflare.com/workers/platform/pricing/ ; https://developers.cloudflare.com/queues/platform/pricing/ | +| **Hyperdrive** | **100,000 database queries/day** (any statement: SELECT/INSERT/UPDATE/DELETE/DDL; cached queries count the same). Resets 00:00 UTC; exceeding fails further ops. **No per-query charge on Paid either** — Paid is simply "Unlimited" queries, with pooling + query caching included in the Workers Paid plan. No egress charge. | (a) Perpetual | Never metered by query. The only "charge" is optionally moving to Workers Paid ($5/mo) for unlimited queries. | $0 per query on both plans | https://developers.cloudflare.com/hyperdrive/platform/pricing/ ; https://developers.cloudflare.com/workers/platform/pricing/ | +| **Vectorize** | Workers pricing table lists, under a "Workers Free" column: **30M queried vector dimensions/month; 5M stored vector dimensions.** ⚠️ **Contradiction flagged:** the same page's heading says "Vectorize is currently only available on the Workers paid plan", while the dedicated Vectorize pricing page presents Free vs Paid columns without that restriction. Treat Free availability as **UNVERIFIED** until confirmed in the dashboard. | (a)/(b) — **UNVERIFIED** | Paid included: first 50M queried dims/mo, first 10M stored dims. | +$0.01 per million queried dims; +$0.05 per 100M stored dims (Workers Paid) | https://developers.cloudflare.com/workers/platform/pricing/ ; https://developers.cloudflare.com/vectorize/platform/pricing/ | +| **Workers AI** | **10,000 Neurons/day free — on BOTH Workers Free and Workers Paid** (single shared account pool across all models; resets 00:00 UTC). Per-model Neuron rates vary widely (e.g. small Llama variants are ~10× cheaper per token than 70B-class models — check the model's page). | (a) Perpetual daily allowance (+ (b) overage on Paid) | Neuron 10,001 in a day: on Free, no overage available (stop); on Paid, metered. | $0.011 per 1,000 Neurons (Workers Paid only) | Secondary summaries of the official pricing page: https://dev.to/sarmaasis/how-i-keep-cloudflare-under-5-and-what-quietly-runs-up-your-bill-om5 — official per-model rates: check Workers AI pricing in developers.cloudflare.com (flagged: official page not re-fetched line-by-line in this pass) | +| **AI Gateway** | **Core features free on all plans:** dashboard analytics, caching, rate limiting; DLP scanning free on all plans (accounts without Zero Trust get 2 predefined DLP profiles). Legacy log storage (gateways created before 2026-09-24): **100,000 logs total across all gateways on Workers Free**. Newer accounts store logs in Workers Logs (see Workers Logs row). No per-request gateway fee. Logpush is a Paid feature. | (a) Perpetual | No gateway meter. Costs appear only via Workers Logs / Logpush / the underlying model provider. | Workers Paid ($5/mo) raises legacy log storage to 10,000,000 logs **per gateway** | https://developers.cloudflare.com/ai-gateway/reference/pricing/ | +| **AI Search (formerly AutoRAG)** | Included per month (both Free and Paid, per limits page): **1,000 semantic queries/mo; 1,000 full-text queries/mo.** Free-specific caps: 100 instances/account (Paid 5,000); max **500 pages crawled/day** on Free (Paid unlimited); 100,000 files/instance. Overage price for queries past 1,000/mo is **not published on the page fetched — UNVERIFIED**. | (a) Perpetual allowance (overage UNVERIFIED) | Query 1,001 in a month (behaviour/price UNVERIFIED). | UNVERIFIED — no rate published on the limits/pricing page fetched | https://developers.cloudflare.com/ai-search/platform/limits-pricing/ | +| **Browser Rendering / Browser Run** | **Workers Free: 10 minutes of browser usage/day; 3 concurrent browsers.** REST API charges duration only; Browser Sessions (Puppeteer/Playwright/CDP) charge duration + concurrency. | (a) Perpetual | On Free: daily cap, no bill (price column is "N/A" for Free). Paid included: 10 browser-hours/mo, 10 concurrent browsers (monthly-averaged). | $0.09 per additional browser hour; +$2.00 per additional concurrent browser (Workers Paid) | https://developers.cloudflare.com/changelog/post/2025-07-28-br-pricing/ | +| **Containers** | **NO free tier. Free column = "N/A" on the official pricing page.** The often-quoted "25 GiB-hours free" is **inside Workers Paid**, not free-standing. Also note container **network egress is metered** (unlike Workers/R2): NA/EU $0.025/GB past 1 TB/mo included; Oceania/Korea/Taiwan $0.05/GB past 500 GB; elsewhere $0.04/GB past 500 GB (egress allowance is part of Paid). | **(b) Allowance inside paid plan ONLY** | From the first container on a Paid account, counting against the included allowance; overage after 25 GiB-hrs / 375 vCPU-min / 200 GB-hrs per month. | Workers Paid $5/mo includes: 25 GiB-hrs memory, 375 vCPU-min, 200 GB-hrs disk / month. Overage: $0.0000025/GiB-second memory; $0.000020/vCPU-second; $0.00000007/GB-second disk | https://developers.cloudflare.com/containers/platform/pricing/ ; https://developers.cloudflare.com/workers/platform/pricing/ | +| **Workflows** | Free: requests **100,000/day shared with Workers requests**; 10 ms CPU/invocation; **1 GB-month storage; 3,000 steps/day.** (Page notes Cloudflare will not bill step/storage usage before a changelog-announced start date.) | (a) Perpetual | Paid included: 10M requests/mo (shared model), 500,000 steps/mo, 1 GB-month storage. | +$0.30/M requests; +$0.02/M CPU-ms; +$0.80 per additional 100,000 steps/mo; +$0.20/GB-month storage (Workers Paid) | https://developers.cloudflare.com/workers/platform/pricing/ | +| **Workers Logs** | **Workers Free: 200,000 log events written/day; 3-day retention.** | (a) Perpetual | Paid included: 20M log events/mo; 7-day retention. | +$0.60 per additional million log events (Workers Paid) | https://developers.cloudflare.com/workers/platform/pricing/ ; https://developers.cloudflare.com/workers/observability/logs/workers-logs/ | +| **Workers Analytics Engine** | **Workers Free: 100,000 data points written/day; 10,000 read queries/day.** | (a) Perpetual | Paid included: 10M data points/mo; 1M read queries/mo. | +$0.25 per additional million data points; +$1.00 per additional million read queries (Workers Paid) | https://developers.cloudflare.com/analytics/analytics-engine/pricing/ | +| **Workers Trace Events Logpush** | **Not on Free** (Paid only): 10M requests/mo included. | (b) Paid only | From first use on Paid. | +$0.05 per million requests (Workers Paid) | https://developers.cloudflare.com/workers/platform/pricing/ | +| **Observability (Logs & Traces — new unified pricing, from 2026-12-01)** | Announced pricing (page updated days before this research; **takes effect 2026-12-01, after this document's date**): **Free: 0.5 GB ingestion/day, 7-day retention included; no paid overage available on Free** (ingestion stops at the daily limit, resumes 00:00 UTC). Covers Workers Logs/Traces, Containers logs, R2 data-access logs, AI Gateway logs, Cloudflare Traces, Issues. **Log Explorer datasets are priced differently: $1/GB ingested, 30-day retention** (see §4). | (a) Perpetual (announced, future-dated) | Paid: 50 GB ingestion + 10 GB-month storage included per billing cycle. | +$0.25/GB ingestion; +$0.10/GB-month storage (Paid) | https://developers.cloudflare.com/observability/pricing/ | +| **Email Routing (inbound)** | **Unlimited inbound emails on both Workers Free and Workers Paid.** Forwarding only (no mailbox); up to 200 routing rules/domain + catch-all per secondary sources (**UNVERIFIED** count); 25 MiB max message. Email Routing *Workers* (processing mail in code) bill as normal Workers usage. | (a) Perpetual | Never for routing itself. | $0 | https://developers.cloudflare.com/email-service/platform/pricing/ | +| **Email Sending (outbound, beta)** | **NOT available on Workers Free at all** (except sends to your own verified destination addresses, which are free on all plans and don't count against quota). | **(b) Allowance inside paid plan ONLY (beta)** | Requires Workers Paid; included allowance is 3,000 outbound emails/mo per account. Hard bounces / accepted emails count; API-rejected sends don't. | +$0.35 per 1,000 emails past 3,000/mo (Workers Paid, $5/mo min) | https://developers.cloudflare.com/email-service/platform/pricing/ | +| **Images — Transformations** | **5,000 unique transformations/month free** (a unique transformation = one source image × one option-set, counted once per month; repeats served from cache don't re-count). Applies to images stored elsewhere / via URL. Media Transformations (video stills/optimisation via Stream) share the same 5,000 free allocation and rate. Workers-binding transformations were **not billed during beta** per Stream pricing page. | (a) Perpetual | Unique transformation 5,001 in a month. | $0.50 per 1,000 monthly unique transformations | https://developers.cloudflare.com/images/pricing/ ; https://developers.cloudflare.com/stream/pricing/ | +| **Images — Stored / Delivered (hosted images)** | **NO free storage.** Storage is Paid-only, sold in blocks. | — Not free | First stored image requires the Paid plan. | $5 per 100,000 images stored/month; $1 per 100,000 images delivered/month | https://developers.cloudflare.com/images/pricing/ | +| **Stream (video)** | **NO standalone free tier.** Storage is prepaid in increments of $5 per 1,000 minutes stored; delivery $1 per 1,000 minutes delivered; ingress & encoding always free. ⚠️ The exception is type (b): **with a Pro or Business zone plan, you get 100 free minutes of video storage + 10,000 free minutes of video delivery every month included** (Cloudflare plans page). | **(b) Allowance inside Pro/Business ONLY** (otherwise not free) | Standalone: from the first minute stored ($5/1,000 min prepaid). On Pro/Business: past 100 min stored / 10,000 min delivered per month. | $5 per 1,000 minutes stored; $1 per 1,000 minutes delivered | https://developers.cloudflare.com/stream/pricing/ ; https://www.cloudflare.com/plans/application-services/ | +| **Realtime (SFU / TURN / WebSocket adapter)** | **First 1,000 GB of egress per month free** — SFU and TURN **share** this one allowance (not 1,000 GB each). Traffic published *into* Cloudflare is free; TURN↔SFU/Stream traffic isn't double-charged. | (a) Perpetual monthly allowance | GB 1,001 of egress in a month. | $0.05 per GB of egress past 1,000 GB | https://developers.cloudflare.com/realtime/sfu/platform/pricing/ | +| **R2 Data Catalog / Basin Catalog, Pipelines, R2 SQL** | No free tier published in this pass; secondary analysis states Pipelines and R2 SQL require Workers Paid. **UNVERIFIED** — treat as not free. | — Not free (UNVERIFIED) | n/a | n/a | https://developers.cloudflare.com/r2/pricing/ | +| **Artifacts** | **Not available on Workers Free at all** ("currently only available on the Workers Paid plan"). Paid includes first 10,000 operations/mo and first 1 GB-mo storage. | (b) Paid only | From first use on Paid. | +$0.15 per additional 1,000 operations; +$0.50 per additional GB-mo (Workers Paid) | https://developers.cloudflare.com/artifacts/platform/pricing/ | +| **Snippets** | **Not free.** Secondary analysis: GA (Apr 2025) made Snippets free for all *paid* plans only; Free-plan access from the alpha was removed. **UNVERIFIED** on an official page in this pass. | — Not free (UNVERIFIED) | Requires a paid plan. | Included in paid plans (no separate price found) | https://dhodrajsundaram.substack.com/p/cloudflare-free-tier-limits | + +--- + +## 4. Trial vs. free — the explicit audit + +**Genuine time-limited trials (type c) found: none on self-serve Cloudflare products.** Specifically checked and **not** trials: + +| Commonly mistaken for a trial | What it actually is | +|---|---| +| **Load Balancing** | Not a trial and not free: a paid add-on starting at $5/mo (500k DNS queries included per the launch post). **VERIFIED 2026-10-25: no trial exists** in any official source (plans page, launch post, billing docs, LB docs). The "15-day trial" claim in the 2026-10-20 reference PDF was an error. | +| **Stream's "100 free minutes"** | Type (b): a recurring monthly allowance *inside* a paid Pro ($20/$25) or Business ($200/$250) zone plan — 100 min stored + 10,000 min delivered, every month, for as long as the plan is paid. Standalone Stream has no free tier. | +| **Containers' "25 GiB-hours free"** | Type (b): included allowance inside Workers Paid ($5/mo). The official pricing table's Free column is literally "N/A". | +| **Email Sending's "3,000 free emails"** | Type (b) + beta: 3,000/mo included only on Workers Paid; unavailable on Free (except free sends to your own verified addresses). It is a beta product, but beta ≠ trial — no expiry was published. | +| **Log Explorer's "first 10 GB free"** | ⚠️ **Conflicting sources — UNVERIFIED.** Third-party summaries cite "$1/GB ingested; first 10 GB free". Cloudflare's own Log Explorer docs (llms-full text fetched in this pass) state the opposite: *"Log Explorer is available as a paid add-on… There is no free version or trial available at this time"*, billed strictly per GB ingested/stored. The newer Observability pricing page prices Log Explorer datasets at $1/GB ingested with 30-day retention (from 2026-12-01 model). **Do not assume any free Log Explorer allowance.** | +| **Workers Paid / Pro / Business themselves** | Subscriptions, not trials: they bill from day one ($5 / $20–$25 / $200–$250). No self-serve free-trial period was published on the plans pages fetched. | +| **Enterprise / Contract features (Bot Management, full API Shield, advanced Waiting Room, MPLS-type network services, etc.)** | Sales-negotiated contracts, sometimes with proofs-of-concept — not self-serve trials, and no public prices. Out of scope for a $5 budget. | + +**Beta ≠ trial:** Email Sending (beta), Browser-Rendering-via-binding billing (beta, currently unbilled), and the Registrar API (beta) are unfinished products, not expiring offers — but beta pricing/terms can change at GA, which is its own risk. + +--- + +## 5. What this means for a $5/month (Workers Paid) budget — quick synthesis + +- **Safely free forever (type a, hard caps, cannot bill you while on Free plans):** DNS/CDN/DDoS/Universal SSL, WAF free ruleset + Bot Fight Mode, Turnstile, Web Analytics, Zaraz ≤1M events/mo, DMARC Management, Email Routing, Zero Trust ≤50 users + Tunnel, Workers/KV/D1/Durable Objects/Queues/Hyperdrive/Workflows/Analytics Engine/Workers Logs within daily caps, Pages ≤500 builds/mo, R2 within monthly allowance (verify billing behaviour — see note), Workers AI ≤10k Neurons/day, Browser Rendering ≤10 min/day, Images ≤5,000 transformations/mo, AI Gateway core, Realtime ≤1,000 GB egress/mo. +- **Free only because you pay $5 (type b — metered overage risk):** Containers allowance, Email Sending 3,000/mo, Vectorize (if Paid-gated), Artifacts, Workers Logpush, plus the Paid included allowances for Workers/KV/D1/DO/Queues themselves. +- **Free only inside a $20+ zone plan (type b):** Stream's 100 stored / 10,000 delivered minutes (Pro/Business). +- **Never free, despite frequent claims:** Load Balancing ($5+), Argo ($5+), Waiting Room (Business+), Images storage ($5/100k), Stream standalone, Log Explorer (per official docs), Cache Reserve, Snippets, Pipelines/R2 SQL. +- **Not free but not a markup either:** Registrar — registry cost only, $0 Cloudflare markup, same at renewal. + +--- + +## 6. Sources (official first) + +Official: developers.cloudflare.com — Workers platform pricing (covers Workers, KV, Hyperdrive, Queues, Workflows, D1, Durable Objects, Vectorize, R2 summary, Containers), R2 pricing, KV pricing, Queues pricing, Hyperdrive pricing, Vectorize pricing, Email Service pricing, AI Gateway pricing, AI Search limits/pricing, Analytics Engine pricing, Workers Logs, Observability pricing, Stream pricing, Images pricing, Realtime pricing, Artifacts pricing, Pages limits, Turnstile plans, Web Analytics limits, API Shield plans, Bot Fight Mode / Bots, WAF feature interoperability, Zaraz pricing, Registrar FAQ; cloudflare.com — plans pages (website plans + add-ons incl. Load Balancing/Argo/Stream/Registrar starting prices), Access/Zero Trust pricing; blog.cloudflare.com — DMARC Management GA, Load Balancing launch, post-quantum WARP; developers.cloudflare.com changelog — Browser Rendering pricing (2025-07-28). + +Secondary (used only where flagged UNVERIFIED in the tables): Substack Free-plan audit (WAF 5-rule / rate-limit detail, Snippets), Omid Saffari (Workers Builds), dev.to cost analyses (Workers AI, Stream/Images bundles), CrowdHandler (Waiting Room tiering). + +*End of research file — prepared 2026-10-20. Re-verify any UNVERIFIED row and all R2/Vectorize/Log Explorer behaviour in the dashboard before relying on it.* diff --git a/doc/2026-11-24T02-42-57Z_research_cloudflare/docs/research-multiple-plans-tos.md b/doc/2026-11-24T02-42-57Z_research_cloudflare/docs/research-multiple-plans-tos.md new file mode 100644 index 000000000..a8d22eb04 --- /dev/null +++ b/doc/2026-11-24T02-42-57Z_research_cloudflare/docs/research-multiple-plans-tos.md @@ -0,0 +1,218 @@ +# Do Cloudflare's terms allow one person to buy multiple Workers plans? + +Researched: 2026-10-20 +Core answer based only on official Cloudflare legal pages and official Cloudflare developer documentation. Labelling used throughout: + +- **(a) Legal text** — what the agreement actually says, quoted. +- **(b) Documented product behaviour** — what Cloudflare's official docs say the product does. +- **(c) Inference** — my reading / implication. Not legal advice. Where the terms are silent, that is stated plainly. + +## Sources (exact URLs) + +1. Self-Serve Subscription Agreement — https://www.cloudflare.com/terms/ + - Page heading on fetch: "Cloudflare Self-Serve Subscription Agreement", "Last Updated September 12, 2025" +2. Service-Specific Terms (overview) — https://www.cloudflare.com/service-specific-terms-overview/ +3. Service-Specific Terms — Developer Platform — https://www.cloudflare.com/service-specific-terms-developer-platform/ + - Covers, per its own heading: "Cloudflare Workers; Cloudflare Pages; Workers KV; D1; Durable Objects; Vectorize; Hyperdrive; Cloudflare Queues; R2; Containers; and Workers for Platforms" +4. Workers pricing — https://developers.cloudflare.com/workers/platform/pricing/ +5. Workers limits — https://developers.cloudflare.com/workers/platform/limits/ +6. Create account — https://developers.cloudflare.com/fundamentals/account/create-account/ +7. Organizations limitations — https://developers.cloudflare.com/fundamentals/organizations/limitations/ +8. Organizations for Enterprise — https://developers.cloudflare.com/fundamentals/organizations/for-enterprise/ + +No Workers-specific standalone terms prohibiting multiple paid plans were found separate from (1) and (3) above. Workers is governed by the Self-Serve Subscription Agreement plus the Developer Platform Service-Specific Terms. + +--- + +## 1. Is a Workers Paid plan per-account or per-user? Can a single account hold more than one Workers Paid subscription? + +### (b) Documented product behaviour: per account + +Workers pricing page, verbatim: + +> "The Workers Paid plan includes Workers, Pages Functions, Workers KV, Hyperdrive, and Durable Objects usage for a minimum charge of $5 USD per month **for an account**. The plan includes increased initial usage allotments, with clear charges for usage that exceeds the base plan." + +Source: https://developers.cloudflare.com/workers/platform/pricing/ + +The same page frames the included allotments per account per month: + +> "10 million included per month +$0.30 per additional million" (requests) +> "30 million CPU milliseconds included per month +$0.02 per additional million CPU milliseconds" + +And, for switching models: + +> "To change your **default account-wide usage model**…" +> "Existing Workers will not be impacted when changing the default usage model. You may change the usage model for individual Workers without affecting your **account-wide default** usage model." + +Workers limits page is headed "Account plan limits" and expresses limits per account, e.g.: + +> "Number of Cron Triggers **per account** | 5 | 250" (Free | Paid) +> "Number of Workers | 100 | 500" under "Account plan limits" + +Source: https://developers.cloudflare.com/workers/platform/limits/ + +### (c) Inference / silence + +- The documentation treats "Workers Free" vs "Workers Paid" as a single plan attribute of **an account**, not a stackable quantity you buy in multiples for the same account. +- **No official page found describes buying two Workers Paid subscriptions on the same account to double the included allotment, and no dashboard/API mechanism for that is documented.** If you need more than the included amount on one account, the documented model is simply pay-as-you-go overage on that same account (e.g. $0.30 / million extra requests), not a second subscription. +- Therefore, in practice: *one account = at most one Workers Paid plan*. To get a second Workers Paid plan you need a second account (see Q2). + +--- + +## 2. Can one person/company hold multiple Cloudflare accounts, each with its own Workers Paid plan? Do the terms restrict creating multiple accounts? + +### Short answer + +- **(b)** Cloudflare itself documents and supports one user creating additional accounts — multiple accounts are a normal product feature, not a hidden workaround. +- **(a)** The legal text does **not** contain a plain blanket sentence such as "you may only have one account" or "you may not buy a Workers plan on more than one account." +- **(a)** The legal text **does** prohibit two specific things that are directly relevant: (i) circumventing usage limits/quotas, and (ii) using software/automation to produce multiple accounts. +- **(c)** So a second *paid* account for a genuinely separate project/business purpose is not prohibited by any clause found; creating accounts specifically as a scheme to multiply free/included allotments, evade a limit, or farm free tiers is exactly the fact pattern the anti-circumvention clauses are written to catch — see quotes below. + +### (a) Legal text — the two key clauses + +Self-Serve Subscription Agreement, §2.2.1 Restrictions — https://www.cloudflare.com/terms/ + +§2.2.1(c): + +> "(c) access or use the Services in a manner that violates or is intended to circumvent Service-specific usage limits, quotas, or other restrictions set forth in the Agreement;" + +§2.2.1(e) — note carefully: this bans *automated* production of multiple accounts, not manual creation as such: + +> "(e) introduce software or automated agents or scripts into the Services so as to produce multiple accounts, generate automated searches, requests or queries, or to strip or mine data from the Services;" + +§2.2.1(a) — also relevant if accounts are being created for / sold to other people: + +> "(a) rent, lease, loan, export, or sell access to the Services to any third party, or sign up for the Services on behalf of a third party;" + +Consequence clause, §8 (same agreement): + +> "If we determine you have breached Section 2.2 or 2.7, we may immediately Suspend or terminate all or part of your use of the Services, or limit End User access to certain of your resources through the Services." + +Free-tier discretion, §2.6 (same agreement): + +> "We may offer free or trial versions of the Services ("Free Services") from time to time… we will make each such Free Service available to you free of charge until the earlier of (a) the end of the free trial period (if applicable)…; (b) the start date of your Subscription Term for the Paid Services version of such Free Service; or (c) termination of the Free Service by Cloudflare in our sole discretion. **We will have no liability for any harm or damage arising out of or in connection with any Free Services.**" + +Acceptable Use, §2.7 (same agreement), prohibits among other things facilitating "phishing, spamming, or other technical abuse" and illegal activity. It contains **no** clause about multiple accounts or multiple subscriptions. + +### (a) Legal text — Developer Platform Service-Specific Terms + +https://www.cloudflare.com/service-specific-terms-developer-platform/ + +Developer Platform §1: + +> "Cloudflare may temporarily limit your storage and/or the number of requests you can make or receive using the Developer Platform if processing such requests would put an undue burden on the Cloudflare network, adversely impact the Service, or otherwise threaten the integrity of Cloudflare's networks." + +Developer Platform §6: + +> "The creation of Developer Platform accounts/projects using subdomains that include deceptive or offensive terms or names of other businesses, organizations, or individuals is prohibited." + +No clause in the Developer Platform terms found that prohibits holding multiple accounts, multiple Workers plans, or splitting projects across accounts. The terms are **silent** on that specific point, beyond the general anti-circumvention and anti-automation clauses in the main agreement quoted above. + +### (b) Documented product behaviour — multiple accounts are explicitly supported + +"Create account" docs — https://developers.cloudflare.com/fundamentals/account/create-account/ + +> "## Create an additional Free account +> +> Existing users can create additional Free accounts in the dashboard or with the API. +> +> ### Eligibility +> +> - Your Cloudflare user must be active and at least seven days old. +> - You must have the Super Administrator role on an existing account. +> - **You can create up to five additional Free accounts.**" + +The same page documents creating accounts via dashboard and via API (user-owned token / OAuth, with an Idempotency-Key), and lists an error for hitting the limit: + +> "| You reached an account creation limit. | Use an existing account or contact your account team. |" + +This is a documented, self-serve flow for *additional* accounts under the *same user* — which strongly cuts against reading the agreement as a one-account-per-person rule. + +### (c) Inference — how the clauses likely apply to two paid accounts + +Labelled inference, not a quote and not legal advice: + +1. **Paying twice is not itself "circumvention" on the face of the text.** Each additional account pays its own $5 minimum and gets its own included allotment, and pays overage beyond that on that account. Nothing found says "one included allotment per natural person / per company, worldwide." +2. **Motive and mechanism matter under §2.2.1(c) and (e).** If the *purpose* of splitting is to avoid a per-account limit/quota that would otherwise apply to what is in substance one workload — e.g. sharding a single app across N accounts solely to harvest N × free daily limits, or spinning accounts with scripts/bots (§2.2.1(e)), or creating fresh accounts to reset a free trial / free tier — Cloudflare could characterise that as use "intended to circumvent Service-specific usage limits, quotas, or other restrictions," and §8 gives it a suspend/terminate remedy. +3. **Separate-purpose accounts are the low-risk pattern the product is built for:** separate projects, separate clients, dev/staging/prod, separate businesses — each with its own billing — are exactly the use case the "create an additional account" docs and the Organizations feature (Q4) describe. The terms do not require you to prove that purpose in advance, but they also do not grant a safe harbour for limit-farming. +4. **Do not use multiple *user identities* to evade the account-creation limits** in Q4 (e.g. five-account cap, seven-day rule). No clause quoted above says "one user per person" in those words, but doing that specifically to evade a documented creation limit falls squarely within the ordinary meaning of §2.2.1(c) circumvention — inference. +5. **Silence statement:** The Self-Serve Subscription Agreement, as fetched 2026-10-20, is **silent** on (i) a maximum number of *paid* accounts per person/company, (ii) whether affiliated companies may each buy Workers Paid, and (iii) any requirement to disclose common ownership of multiple self-serve accounts. Do not treat silence as permission for limit-evading schemes — the anti-circumvention clause is purpose-based, not count-based. + +--- + +## 3. Practical differences: is usage pooled per account? Is getting multiple pools itself a violation? + +### (b) Documented product behaviour: yes, pooled per account, not per user + +From the pricing page (URL above): + +- Included amounts reset monthly, per subscription/account: all included usage is stated "on a monthly basis"; D1 note on the same page: "Monthly included limits reset based on your monthly subscription renewal date, which is determined by the day you first subscribed." +- Aggregation is within the account, e.g. for D1 storage: "Storage is based on gigabytes stored per month, and is based on **the sum of all databases in your account**." +- Workers usage model is "account-wide" by default, overridable per-Worker within that account (quote in Q1). + +Consequences that follow mechanically from (b): + +| | One account, Workers Paid | Two accounts, each Workers Paid | +|---|---|---| +| Minimum charge | $5 / month | $5 + $5 = $10 / month | +| Included requests | 10M / month, pooled across all Workers in the account | 10M / month **per account**, separate pools | +| Included CPU | 30M CPU-ms / month, pooled | 30M CPU-ms / month per account | +| Workers per account | 500 | 500 per account | +| Cron Triggers per account | 250 | 250 per account | +| Billing / renewal date | One subscription | Two separate subscriptions, potentially different renewal dates | +| Data / bindings | KV, D1, R2, DO, Queues live in that account | Separate namespaces/databases/buckets per account; no automatic sharing | + +Workers in different accounts do not share an included pool, and overage in one account is not offset by unused included usage in another. + +### (a) / (c) Is having multiple pools a violation? + +- **(a)** No clause found says "thou shalt have only one included pool." The existence of separate pools is simply how per-account billing works. +- **(c)** The violation risk is not *having* two pools, it is *why and how* you got them — see Q2 inference points 2 and 4. Two paid accounts for two real projects, each paying its own minimum: no clause found prohibits it. A fleet of accounts created by automation, or split for the sole purpose of defeating a per-account quota/free limit that would otherwise bind a single workload: §2.2.1(c)/(e) risk, plus §2.6 gives Cloudflare sole-discretion termination for Free Services. + +--- + +## 4. Adjacent documented limits: how many accounts / zones in practice? + +### (b) Additional Free accounts under one user (self-serve) + +Source: https://developers.cloudflare.com/fundamentals/account/create-account/ (quotes in Q2) + +- Up to **five additional Free accounts** per eligible user (in addition to the original account). +- User must be active and **at least seven days old**. +- User must have **Super Administrator** role on an existing account. +- API creation requires a user-owned token / OAuth (account-owned tokens cannot create accounts), `standalone: true`, and an Idempotency-Key. + +No equivalent published self-serve number was found in the official docs fetched for "maximum paid accounts per user." The docs only document the Free-account creation flow and its cap; upgrading/creating a paid account is a billing/subscription action on an account. **Silence in docs ≠ no internal limit** — the error table itself acknowledges an "account creation limit" that can be hit. + +### (b) Organizations (Enterprise / MSSP — not ordinary self-serve) + +Source: https://developers.cloudflare.com/fundamentals/organizations/limitations/ + +> "Each Organization supports a maximum of **20,000 accounts** and **200,000 zones**. This limit applies to both Enterprise and MSSP/Distributor Organizations. These limits are defaults and can be adjusted for larger enterprises and partners in some cases." + +Source: https://developers.cloudflare.com/fundamentals/organizations/for-enterprise/ + +> "One Organization contains multiple accounts… Maximum: **20,000 accounts** and **200,000 zones** per Organization" +> Example given by Cloudflare itself: "Company A is a SaaS company with **12 Cloudflare accounts**: 3 accounts for different product lines… 3 environments per product (Development, Staging, Production)" + +That official example is useful context for Q2: Cloudflare's own documentation presents a single company holding a dozen accounts for product/environment separation as a normal pattern. + +Prerequisite noted on that page: Organization creation requires an Enterprise plan account, Super Admin, and 2FA/SSO — so this is not a self-serve workaround for the five-account creation cap. + +### (b) Per-account Workers limits that make a second account tempting — and why intent matters + +Source: https://developers.cloudflare.com/workers/platform/limits/ ("Account plan limits") + +- Workers per account: **100 (Free) / 500 (Paid)** +- Cron Triggers per account: **5 (Free) / 250 (Paid)** +- Free daily requests: **100,000/day per account** (pricing page / limits page: accounts on Free have a daily request limit of 100,000, Error 1027 on excess) + +### Zones + +- No hard self-serve per-account zone (domain) cap was stated in the official pages fetched, other than the Organization-level 200,000 zones above. That is a finding of *absence in the sources checked*, not a guarantee that no internal/anti-abuse zone limit exists. Do not cite a specific self-serve zone maximum from this file. + +--- + +## Bottom line (one paragraph) + +**(a)+(b)** A Workers Paid plan is a per-account subscription ($5/month minimum per account, one plan per account in the documented model; usage and included allotments pool per account). Cloudflare's own docs support one user creating additional accounts (up to five additional Free accounts self-serve, subject to age/role requirements), and each such account can carry its own paid subscriptions — no clause found imposes a one-plan-per-person rule. **(a)** What the Self-Serve Subscription Agreement does prohibit is (c) using the Services in a manner "intended to circumvent Service-specific usage limits, quotas, or other restrictions" and (e) using "software or automated agents or scripts… so as to produce multiple accounts," with suspension/termination as the remedy for breaching §2.2. **(c)** So: buying a second Workers Paid plan on a second, genuinely separate account is not prohibited by any text found; manufacturing/splitting accounts — especially automatically, or to farm free tiers / multiply included allotments for what is really one workload to dodge a limit — is the conduct those clauses target, and the terms give Cloudflare discretion to act on it. When in doubt, the safe, documented alternative for "I need more on this workload" is overage on the single account, Workers for Platforms, or asking Cloudflare Support / Sales for a limit increase in writing. diff --git a/doc/2026-11-24T02-42-57Z_research_cloudflare/docs/research-paid-only.md b/doc/2026-11-24T02-42-57Z_research_cloudflare/docs/research-paid-only.md new file mode 100644 index 000000000..30c0ffca3 --- /dev/null +++ b/doc/2026-11-24T02-42-57Z_research_cloudflare/docs/research-paid-only.md @@ -0,0 +1,317 @@ +# Cloudflare Paid-Only & Enterprise Features — Research for Reference Document + +**Date:** 2026-10-20 +**Scope:** Research task 3 of 3 — what is *not* free, split by affordability for a solo developer already on Workers Paid ($5/mo). +**Budget lens used in this file:** The user wants to stay at the $5 already spent, and not add another $5 / $10 / $20 lightly. Section A is therefore the $5–$50/mo “could buy if it solves a real problem” set. Section B is custom-contract / enterprise-only and not realistic on a personal budget. +**Method:** Official Cloudflare sources first — `cloudflare.com/plans`, `cloudflare.com/plans/application-services/`, and per-product pricing pages on `developers.cloudflare.com` — checked 2026-10-20. Where Cloudflare does not publish a price, this file says **“custom pricing, not published”** and flags it **UNVERIFIED** for any third-party estimate. Third-party estimates are never presented as Cloudflare list price. + +> **Important change found in Oct 2026 research:** Logpush was historically Enterprise-only. As of the 2 Oct 2026 Observability launch it is now self-serve on Free / Pro / Business with usage pricing. See Section A.14. Anything in older blog posts calling Logpush “Enterprise-only” is now out of date for the base export feature, though Enterprise Log Share / long-retention contracts remain enterprise. Sources: https://blog.cloudflare.com/one-observability-platform/ and https://developers.cloudflare.com/logs/logpush/pricing/ + +--- + +## A) AFFORDABLE PAID-ONLY / ADD-ON FEATURES — $5–$50/mo range for a solo dev + +### A.0 Baseline: Zone plans that gate most add-ons + +#### Pro plan — $20/mo billed annually, $25/mo billed monthly, per zone +- **What it is:** First paid zone plan. Adds managed WAF rulesets + OWASP, 20 custom WAF rules (155 Cloudflare Rules total in current plans table), Polish lossless image optimisation, Mirage / mobile optimisation, APO included, DDoS alerts, ticket support. +- **Exact price:** $20/mo annual / $25/mo monthly, per domain/zone — not per account. +- **Solo verdict:** **Borderline — the single most plausible zone upgrade.** It is 4× the current Workers Paid spend for one zone. Worth it only if that zone needs WAF managed rules, Polish, or APO included. For a pure Workers / R2 / D1 API with no origin website, it buys almost nothing. +- **Source:** https://www.cloudflare.com/plans/ + +#### Business plan — $200/mo billed annually, $250/mo billed monthly, per zone — OUT OF THE $5–$50 RANGE +- **What it is:** Adds custom SSL upload, 100% uptime SLA (1× credits), 100 custom WAF rules (310 Rules total), Cache Bypass on Cookie, PCI / SOC 2 positioning, Super Bot Fight Mode + Bot Analytics, Waiting Room (1 room, see A.17), chat support. +- **Exact price:** $200 annual / $250 monthly, per zone. +- **Solo verdict:** **Wouldn’t buy on a personal budget** — listed here only because several features below (Waiting Room, Advanced Rate Limiting inclusion, custom certs) are gated to Business, so the reader understands the gate is $200, not $20. 40× the Workers Paid base. +- **Source:** https://www.cloudflare.com/plans/ + +#### Workers Paid overages — the plan already owned +- **What it is:** Not a new purchase. $5/mo minimum includes 10M requests/mo + 30M CPU-ms/mo. This line covers what happens *past* included usage, which is the realistic “extra Workers Paid usage” the brief asked about. +- **Exact price:** +$0.30 per additional million requests, +$0.02 per additional million CPU-ms. Workers Logs: 20M events included, +$0.60 / million. Workers KV (Paid): 10M reads included +$0.50/M, 1M writes included +$5.00/M, 1 GB stored included +$0.50/GB-mo. Queues: 1M ops included +$0.40/M. Durable Objects and D1 detailed in A.19–A.20. +- **Solo verdict:** **Keep — this is the best-value paid line in the whole catalog.** Example in official docs: 15M requests at 7 ms avg = $8.00 total. 100M requests at 7 ms = $45.40 total. Costs only bite with KV writes in a hot path ($5/M) or always-on Durable Objects. +- **Source:** https://developers.cloudflare.com/workers/platform/pricing/ + +--- + +### A.1 Smart Shield + Argo Smart Routing (incl. Tiered Cache) +- **What it is:** Uses Cloudflare’s real-time network congestion data to route origin fetches / dynamic requests around slow paths. Bundle on the plans page is sold as “Smart Shield + Argo” and explicitly *includes Smart Routing and Tiered Caching*. +- **Exact price:** **Starting at $5/mo per zone** on the official plans page. Usage beyond the first GB is metered — Cloudflare’s long-published rate is **$0.10/GB of Argo-routed traffic**. The $0.10/GB figure is confirmed in Cloudflare billing / launch material summarised in search, but the plans page itself only shows the $5 starting price, so budget as $5 + $0.10/GB and verify in dashboard before enabling. At 100 GB = ~$15; at 1 TB = ~$105 — it stops being “affordable” fast. +- **Solo verdict:** **Wouldn’t buy for a cached static / Workers site** (requests never hit origin, so there is nothing to smart-route). Plausible only for a dynamic origin API with global users where 30–50 ms matters. Tiered Cache alone (see A.10) is now available without Argo on paid plans and is the part most solo devs actually wanted. +- **Sources:** https://www.cloudflare.com/plans/ and https://www.cloudflare.com/plans/application-services/ + +### A.2 Load Balancing +- **What it is:** Global / local load balancer in DNS / Traffic: pools of origins, health monitors, failover, geo-steering and (higher plans) session affinity. Protects against a single origin / VPS dying. +- **Exact price:** **Starting at $5/mo** on official plans page. Dashboard billing example in developers docs shows “Basic Load Balancing — $5.00” as a flat add-on line. Included starter allocation historically: 2 origins / pools and 500,000 DNS queries/mo; **+$5/mo per additional origin** beyond included — that per-origin detail is from Cloudflare’s add-on breakdowns, verify in dashboard as allocations change by plan. Queries beyond included are metered in dashboard at subscription time. +- **Solo verdict:** **Reasonable $5 buy *if* you have 2+ origins.** For a single-origin or Workers-only deployment it does nothing. One of the few add-ons with a clean, predictable $5 entry. +- **Sources:** https://www.cloudflare.com/plans/ , https://developers.cloudflare.com/billing/understand/how-billing-works/ , https://blog.cloudflare.com/introducing-load-balancing-intelligent-failover-with-cloudflare + +### A.3 Advanced Certificate Manager (ACM) + Total TLS +- **What it is:** ACM lets you choose CA (Let’s Encrypt / Google / SSL.com etc.), validity period, cipher suites, ECDSA/RSA, multi-level wildcard (`*.api.example.com`), and issue advanced cert packs per hostname. **Total TLS** is the ACM feature that automatically issues individual certs for every proxied hostname / subdomain so no subdomain goes uncovered — it requires ACM, it is not a separate SKU. +- **Exact price:** **$10/mo per zone** — “Starting at $10 per month” on official plans page, confirmed as $10/mo/zone in ACM docs/blog. +- **Solo verdict:** **Wouldn’t buy unless** you need a second-level wildcard, a specific CA, or Total TLS for many subdomains. Universal SSL (free) already covers apex + first-level wildcard. This is a compliance / multi-tenant feature, not a personal-site need. +- **Sources:** https://www.cloudflare.com/plans/ , https://www.cloudflare.com/plans/application-services/ + +### A.4 Automatic Platform Optimization (APO) for WordPress +- **What it is:** One-click WordPress edge caching + optimisation plugin: caches HTML at edge, bypasses for logged-in users, optimises fonts / third-party JS. +- **Exact price:** **$5/mo on Free plan; included on Pro / Business / Contract.** Stated verbatim on plans page. +- **Solo verdict:** **Only if you run WordPress.** Irrelevant to a Workers / Astro / static stack. If you do run WP on a Free zone, $5 APO is cheaper than jumping to $20 Pro just for APO. +- **Source:** https://www.cloudflare.com/plans/ + +### A.5 Cache Reserve +- **What it is:** Persistent cache on top of R2. Normally edge cache evicts under pressure; Cache Reserve keeps cacheable assets (TTL ≥10 hours, with Content-Length) in R2 as an ultimate upper tier for up to 30 days (retention resets on request), shielding origin and saving origin egress. +- **Exact price:** **Pure usage, no flat fee, but requires a paid plan.** Storage $0.015/GB-mo, Class A writes $4.50/million, Class B reads $0.36/million — identical to R2 Standard. Worked example in official docs: 1,000 × 1 GB assets, 1,000 reads each = $19.86/mo ($15 storage + $0.36 reads + $4.50 writes pro-rated). +- **Solo verdict:** **Cheap and sensible for image/file-heavy sites with an origin that charges egress.** For Workers + R2 origin there is no origin egress to save, so it adds cost for little gain. Watch Class A churn — daily-expiring assets rewritten daily can push a 1M-asset example to $171.60/mo in docs. +- **Source:** https://developers.cloudflare.com/cache/advanced-configuration/cache-reserve/ + +### A.6 Tiered Cache (Smart Tiered Cache) +- **What it is:** Hierarchy of Cloudflare caches: lower-tier PoPs fill from a designated upper-tier PoP instead of every PoP independently fetching origin. Dramatically cuts origin fetches and improves hit ratio. Variants: Generic Global, Smart (topology-aware, recommended). +- **Exact price:** **No separate line-item in current pricing.** Historically bundled with Argo; the current Smart Shield + Argo bundle lists Tiered Caching as included, and Tiered Cache itself is enable-able on paid plans at no usage fee. **Flag:** If dashboard shows Tiered Cache under Argo for your zone, do not assume enabling Smart Tiered Cache alone triggers the $0.10/GB Argo meter — verify the toggle is “Tiered Cache” not “Argo Smart Routing”. +- **Solo verdict:** **Enable it — it’s the free win in this section.** No downside for most sites except slightly higher latency on a true miss via upper tier. +- **Source:** https://www.cloudflare.com/plans/ (Argo bundle includes Tiered Caching) + +### A.7 Cloudflare Images (Paid) +- **What it is:** Store originals in Images, serve resized / AVIF/WebP variants, or transform remote / R2 images via URL or Workers binding. Different from free Polish (Pro zone feature). +- **Exact price:** Free: 5,000 unique transformations/mo, no storage. **Paid: Images Transformed $0.50 per 1,000 unique transformations beyond 5,000 included; Images Stored $5 per 100,000 images/mo; Images Delivered $1 per 100,000 delivered/mo.** Storage sold in $5 blocks. +- **Solo verdict:** **Good $5 buy if you serve many image sizes.** For a handful of images, R2 + free transformations (5k/mo) is enough and costs $0. Note transformations are billed *per unique combination per month* — a responsive site with 6 sizes × 2,000 images = 12,000 transformations = $3.50 overage. +- **Source:** https://developers.cloudflare.com/images/pricing/ + +### A.8 Cloudflare Stream +- **What it is:** Video storage, encoding (adaptive bitrate), player, live ingest (RTMP/SRT/WebRTC), and delivery — priced by minutes, not GB, with encoding + bandwidth included. +- **Exact price:** **Storage: $5 per 1,000 minutes stored (prepaid blocks). Delivery: $1 per 1,000 minutes delivered (postpaid).** Pro/Business zones include 100 min stored + 10,000 min delivered/mo. Plans page: “Starting at $5 per month for 1,000 minutes of video stored.” +- **Solo verdict:** **Affordable entry, scales linearly.** 10 hours stored = ~$3 in a $5 block; 1,000 viewers × 10 min = 10,000 delivered min = $10. Cheaper and far simpler than self-hosting video, but for 2–3 embedded clips YouTube/Vimeo free embed or R2 + `