# Limits, cost and when to split

The Workers Paid, Hyperdrive and Neon limits the template runs under, what a daily user costs, why the database is the first bottleneck, and the triggers that would justify a second Worker.

Production runs on Workers Paid ([ADR-0017](/docs/adr/0017-production-runs-on-workers-paid)) as one Worker ([ADR-0020](/docs/adr/0020-one-worker-and-four-seams)). This page holds the numbers behind both decisions. The [production guide](/docs/production) covers regions, backups and the monthly bill of a small project.

<Callout title="Figures on this page">
Limits and prices were read on **2026-11-28** from the pages linked in each row. The traffic
figures are estimates with their assumptions shown, not measurements: no production CPU, memory or
statement timing is recorded in the repository yet. Read the linked page again before you quote a
limit, and replace an estimate when you have a measurement.
</Callout>

## Limits [#limits]

| Limit                             | Value on Workers Paid                                                                                                                                                          | Where the template is                                                                                                                                         | Source                                                                                                                                                                                 |
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| CPU per request                   | 30 s by default, 5 min at most. "Heavier workloads that handle authentication, server-side rendering, or parse large payloads typically use 10-20 ms."                         | Not measured in production. At 10 to 20 ms: 1,500 times under the default.                                                                                    | [Workers limits](https://developers.cloudflare.com/workers/platform/limits/)                                                                                                           |
| Memory                            | 128 MB per isolate, shared by its concurrent requests                                                                                                                          | Not measured                                                                                                                                                  | same                                                                                                                                                                                   |
| Subrequests                       | 10,000 per request (50 on Free)                                                                                                                                                | A page makes tens                                                                                                                                             | same                                                                                                                                                                                   |
| Simultaneous outgoing connections | 6 waiting for response headers; the 7th queues                                                                                                                                 | The request pool is `max: 5` (`packages/db/src/index.ts`); it queues, it does not fail                                                                        | same                                                                                                                                                                                   |
| Script size                       | 64 MiB uncompressed, no compressed limit since 2026-09-04                                                                                                                      | 29,293,272 B of server modules on 2026-11-28, 44% of the limit; the docs chunk is 4,542,362 B of it ([ADR-0018](/docs/adr/0018-docs-compile-into-the-worker)) | same; [changelog](https://developers.cloudflare.com/changelog/post/2026-09-04-increased-worker-size-limit/)                                                                            |
| Startup                           | 1 s                                                                                                                                                                            | About 50 ms locally ([ADR-0010](/docs/adr/0010-procedures-run-one-effect-program))                                                                            | same                                                                                                                                                                                   |
| Wall time                         | None for HTTP while the client is connected; 15 min for cron; 30 s for `waitUntil`                                                                                             | The cron tick's own deadline is 25 s                                                                                                                          | same                                                                                                                                                                                   |
| Requests                          | 10 million a month included in the $5; $0.30 per further million                                                                                                               | See [cost](#cost-by-daily-users)                                                                                                                              | [Workers pricing](https://developers.cloudflare.com/workers/platform/pricing/)                                                                                                         |
| CPU price                         | 30 million ms a month included; $0.02 per further million ms                                                                                                                   | See [cost](#cost-by-daily-users)                                                                                                                              | same                                                                                                                                                                                   |
| Service binding                   | "zero overhead or added latency", "do not incur additional request fees"; billed as one request plus the CPU of both Workers; depth 32                                         | None today. A split would cost the same to run.                                                                                                               | [Service bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/)                                                                                  |
| Hyperdrive origin connections     | About 20 on Free; up to 1,500 per configuration on Paid (raised from 100 on 2026-11-11); minimum 5; statements up to 60 s; transaction pooling; client connections not limited | The configured limit is a per-project setting, not in the repository                                                                                          | [Hyperdrive limits](https://developers.cloudflare.com/hyperdrive/platform/limits/), [changelog](https://developers.cloudflare.com/changelog/post/2026-11-11-hyperdrive-raised-limits/) |
| Neon connections                  | 112 at 0.25 CU (7 reserved), 225 at 0.5, 450 at 1, 901 at 2, 1,802 at 4. Hyperdrive uses the direct connection string, so these are the ceiling.                               | The compute size is a per-project setting                                                                                                                     | [Neon pooling](https://neon.com/docs/connect/connection-pooling), [Neon with Hyperdrive](https://neon.com/docs/guides/cloudflare-hyperdrive)                                           |
| Neon compute price                | Launch: $0.106 per CU-hour, autoscaling to 16 CU. Free: 100 CU-hours a month, up to 2 CU.                                                                                      | See [the database](#the-database-is-the-first-bottleneck)                                                                                                     | [Neon plans](https://neon.com/docs/introduction/plans)                                                                                                                                 |
| WebSockets                        | No documented maximum per Worker; 32,768 per Durable Object                                                                                                                    | None today                                                                                                                                                    | [Durable Object state](https://developers.cloudflare.com/durable-objects/api/state/)                                                                                                   |

## Requests per active user per day [#requests-per-active-user-per-day]

Estimates, read from the code's behaviour:

- **Web, about 100.** Two visits of 12 navigations each: 2 server-rendered documents (their data is read in process, with no further request), 22 client navigations at 1.5 batched `/api/rpc` calls (33), 15 mutations, 10 session reads (refetch on window focus with a 15 s stale time), 24 page-view events, 4 web-vitals posts and 5 file operations. That is about 93. Polling exists only on the integrations and billing screens, so nothing runs for every open tab.
- **Mobile, about 80.** Five opens of 6 requests (session, first screen, screen views), 20 further screens at 2 requests, 10 mutations. The arithmetic below uses 100.
- **Cron.** 1,440 invocations a day whatever the traffic.

## Cost by daily users [#cost-by-daily-users]

| Daily users | Requests a month | Worker fee          | How                                                                                                                                                       |
| ----------- | ---------------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 1,000       | 3 million        | Free plan's ceiling | 100,000 requests a day ÷ 100. The Free plan's 10 ms CPU cap is under what an SSR or auth request typically uses, which is why the template requires Paid. |
| 3,300       | 10 million       | $5                  | The included requests: 10,000,000 ÷ 30 ÷ 100                                                                                                              |
| 10,000      | 30 million       | about $15           | $5 + 20 × $0.30 = $11, plus CPU at an assumed mean of 8 ms: 240 million ms, 210 × $0.02 = $4.20                                                           |
| 100,000     | 300 million      | about $139          | $5 + 290 × $0.30 = $92, plus CPU: 2,400 million ms, 2,370 × $0.02 = $47.40                                                                                |

The CPU limit is not in reach: a request would need 30,000 ms, and no RPC or SSR path is within three orders of magnitude. Only a CPU-bound endpoint could meet it; OG rendering is cached and document conversion runs in the browser ([ADR-0008](/docs/adr/0008-documents-and-large-uploads)). The script would need more than two years of growing by 5 MB a quarter to reach 64 MiB.

## The database is the first bottleneck [#the-database-is-the-first-bottleneck]

- **Peak load.** Assume 10% of the day's requests in the busiest hour and a 2× burst inside it: requests per second ≈ daily users × 100 × 0.10 ÷ 3,600 × 2 = daily users × 0.0056. That is about 56 a second at 10,000 daily users and 560 at 100,000.
- **Connections.** Hyperdrive pools in transaction mode, and each tenant statement is its own short transaction ([tenant isolation](/docs/features/database#tenant-isolation)). With about 3 statements a request at about 3 ms each, a request holds an origin connection for about 10 ms: 560 requests a second need about 6 connections on average and perhaps 30 to 60 in a burst, which fits the 105 usable connections of 0.25 CU. The connection count does not bite; hold time does. One 2 s statement on 50 requests a second is 100 connections. This is why `withTenant` forbids network I/O and why the job pool has 1.5 s and 2 s timeouts.
- **Compute.** At an assumed 1 ms of database CPU per request (three indexed statements, each evaluating the row-level security predicate), 0.25 CU saturates near 250 requests a second, about 45,000 daily users, and 1 CU near 1,000, about 180,000. Replace these with a load test; the order is what matters.
- **Cost.** The every-minute cron keeps the compute awake ([production guide](/docs/production#the-cron-keeps-the-database-awake)). 0.25 CU all month is 182 CU-hours: over the Free plan's 100, and $19 a month on Launch. 1 CU is $77 and 4 CU is $310. The database costs more than the Worker at every level in the table above.
- **Search.** `ILIKE` and `@@` cannot use an index under row-level security ([ADR-0009](/docs/adr/0009-row-level-security)). A search feature reaches the database's limit long before any Worker limit.

Splitting the API into its own Worker moves none of these: it would open the same connections to the same database.

## When a second Worker is justified [#when-a-second-worker-is-justified]

Measure before deciding: CPU per request by route from Workers Logs, the raw bundle size, the p95 statement time and Hyperdrive pool errors.

| Trigger                                                                                                                                 | First response                                                                                                         |
| --------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| A second team or release cadence, or a third-party or non-JavaScript consumer that needs a versioned API with its own availability goal | Split on the same host ([ADR-0019](/docs/adr/0019-api-stays-on-the-app-host)); the contracts are already the interface |
| An endpoint over about 1 s of CPU at p95, or work over 30 s                                                                             | Move that endpoint to its own Worker, a Queue or a Workflow, not the API                                               |
| WebSockets or presence                                                                                                                  | A Durable Object beside the Worker, not the API                                                                        |
| Raw Worker bundle over 40 MiB, or startup over 400 ms                                                                                   | Stop compiling docs into the Worker first; split second                                                                |
| Compliance that pins the API and the data to a jurisdiction while pages render globally                                                 | Split, with [placement](/docs/production#worker-placement) on the API Worker                                           |
| p95 statement over 50 ms, or Hyperdrive "Failed to acquire a connection from the pool"                                                  | Indexes, compute size, a read replica. A split does not help.                                                          |

Until one fires, the four seams of ADR-0020 keep the split cheap; they are stated as rules in [`AGENTS.md`](https://github.com/CarlosZiegler/template-cloudflare/blob/main/AGENTS.md).

## Key files [#key-files]

- [`docs/adr/0017-production-runs-on-workers-paid.md`](https://github.com/CarlosZiegler/template-cloudflare/blob/main/docs/adr/0017-production-runs-on-workers-paid.md)
- [`docs/adr/0020-one-worker-and-four-seams.md`](https://github.com/CarlosZiegler/template-cloudflare/blob/main/docs/adr/0020-one-worker-and-four-seams.md)
- [`scripts/measure-worker-build.mjs`](https://github.com/CarlosZiegler/template-cloudflare/blob/main/scripts/measure-worker-build.mjs)
- [`scripts/docs-chunk.mjs`](https://github.com/CarlosZiegler/template-cloudflare/blob/main/scripts/docs-chunk.mjs)
- [`apps/web/wrangler.jsonc`](https://github.com/CarlosZiegler/template-cloudflare/blob/main/apps/web/wrangler.jsonc)
