# Beta limits

> What every Cairnflow Cloud environment is allowed during the Beta, and what happens at each limit.

Source: https://cairnflow.dev/docs/cloud/limits

:::caution[Early-access waitlist]
Cairnflow Cloud is not open yet — [join the waitlist](/#pricing) to hear when early access opens.
This page describes the hosted service as it is built for its Beta, and details may change before
it opens. To run cairnflow today, [host it yourself](/docs/self-hosting).
:::

Every environment has the same Beta plan. Your environment page shows it under **Plan & limits**,
and `GET /tenant` with an Admin key returns your environment's limits and current usage.

## Plan limits

| Limit | Beta | At the limit |
|---|---:|---|
| Finished invocations kept | 7 days | Removed after that (archived first; see [Data and deletion](/docs/cloud/data-and-deletion)) |
| Largest payload | 1 MiB | A request body over it gets `413` with code `payload_too_large`. Larger state values, step results, inputs and outputs inside an invocation are stored as segments instead (see [Payload](#payload)) |
| Journal entries per invocation | 10,000 | The invocation fails with code `578` (`journal_too_long`) |
| Live invocations, whole environment | 1,000 | A new invocation gets `429` with code `live_invocations_limit`, and nothing is created. Schedules skip the runs that come due meanwhile. Invocations already running carry on, and so do the calls and sends they make |
| Deployments | 20 | Registering one more gets `409` with code `deployments_limit`. Remove a deployment that is no longer current to free a slot (see [Deployments](/docs/cloud/deployments#ship-a-new-version)) |
| Deployment registrations | 10 per minute | `429` with code `deploy_rate_limited` and a `Retry-After` header |
| Schedules | 50 | Creating one more gets `409` with code `schedules_limit`. Changing an existing schedule still works |
| Pending timers per invocation | 1,000 | The invocation fails with code `579`; the message starts with `timers_limit` |
| State keys per virtual object or workflow | 10,000 | Writing a new key fails the invocation with code `579`; the message starts with `state_keys_limit` |
| Artifact storage, whole environment | 1 GiB | Storing another artifact fails the invocation with code `579`; the message starts with `artifacts_limit` |
| Sustained throughput | 200 compute units per second | New work waits and runs as capacity frees up |
| Burst | 400 compute units | |
| Open streams and attached waits, per environment and node | 256 | `429` with code `too_many_open_streams` |

### Live invocations and artifact storage

Both are counted every few seconds, so an environment can go a little over either one before new
work is refused. An invocation is live while it runs, waits or is paused; it stops counting when
it ends. Artifacts stop counting when the invocation that stored them is purged, by you or at the
end of retention.

### Compute units

A compute unit (CU) is one per durable step, one per invocation created, and one per started
100 ms that each turn is open. A turn is open while your service works on it, and that includes
time your handler waits inside `ctx.run`, for example for a model to answer. Time an invocation
spends suspended is not counted: after a `ctx.sleep`, or while it waits on a promise, an
awakeable, a signal or another invocation, the SDK ends the turn and nothing is counted until the
next one starts. A handler that sleeps for a week costs nothing while it sleeps.

At 200 CU per second, about 20 turns can be open at once in an environment; further turns wait for
capacity. The console's **Usage** page shows compute units per hour and per handler.

### Payload

The payload limit applies to each request body sent to your environment. Inside an invocation,
values larger than 256 KiB (state values, `ctx.run` results, invocation inputs and outputs,
promise values) are stored as immutable segments in your environment's storage. The journal keeps
references, and a turn sends only the open tail of a value and what changed. Your code sees the
whole value as before; nothing in the SDK API changes.

A conversation history in `chatObject` therefore grows past the payload limit without trimming.
We test histories up to 8 MiB. One value read back in a single response, such as the history from
`transport.messages` or an output from the HTTP API, is capped at 64 MiB. See
[Vercel AI SDK](/docs/agents/vercel-ai-sdk#size-and-cost).

Files and images still belong in [artifacts](/docs/develop/artifacts): they are bytes your code
stores and passes by reference, not values it reads back on every turn.

### Journal length

Each step, sleep, call, state read or write and promise is a journal entry. An invocation that loops
for a very long time should hand over to a fresh invocation (`ctx.continueAsNew`) rather than grow
one journal without end.

### Open streams

Each SSE stream reader (a chat page following a turn, for example) and each request waiting for an
invocation's result holds a connection. The cap is per environment on each node of the cell. The
chat transport retries a refused connection with backoff.

## Turn time limit

In request-response mode, each turn of a handler is one HTTP request, and it must finish within the
handler's `inactivityTimeout`: **60 seconds** unless the service or the handler declares a longer
one, up to one hour (see [Handler options](/docs/develop/services#handler-options)). Like every
handler option, it is read when you register the deployment.

A turn that takes longer is cut and retried. The step it was running starts again from the
beginning on the next attempt (a model call is made, and paid for, again), and without a retry
policy the retries do not stop. Keep each `ctx.run` well under the limit, declare a longer
`inactivityTimeout` for the handlers that need one, and set a
[retry policy](/docs/develop/errors-retries#retry-policy) with `maxAttempts`.

Request-response is how Cloud calls an `https://` endpoint unless you register it with
`"transport": "declared"`, and the only mode of `fetchHandler`. Only the streaming transport
(`BIDI_STREAM`) keeps the connection alive while a closure runs, so a long step is not cut there.
On a serverless platform a turn must also finish within the platform's own time limit, and a proxy
or tunnel in front of your service may have its own.

## Runtime limits

These come from the runtime and apply to every environment:

| Limit | Value |
|---|---|
| Streams per invocation | 16 |
| Temporary stream buffer, per stream | 1 MiB (older records are overwritten) |
| Temporary stream kept after the invocation ends | about 60 seconds |
| `ctx.log` per invocation | 1 MiB |
| Trace spans per invocation | 1 MiB |
| Durable streams per invocation, together | 8 MiB |
| One SSE connection | at most 10 minutes; clients reconnect |
| SQL query | 200,000 read units, 128 MiB, 10 seconds (up to 30 seconds with `timeout_ms`), 10,000 rows |
| SQL queries at once | 4 per node, 2 of them per environment |

Records over a stream or log cap are dropped and replaced by a `gap` marker; an invocation never
fails because of a stream.

## Account limits

Cloud is invite-only during the Beta: only an invited email address can create an organization,
and environments can be created only in an organization whose owner was invited. People you invite
into your organization do not need an invitation of their own. Invitations have not started.

| Limit | Beta | At the limit |
|---|---:|---|
| Organizations one person can create | 2 | `409` with code `org_limit` |
| Environments per organization | 3 | `409` with code `env_limit` |
| API keys per environment, active or being revoked | 20 | `409` with code `key_limit` |

A deleted environment or a revoked API key frees its place once the deletion or revocation has
finished. Changes made through the Cloud web app and its API are rate limited per person: over the
limit they get `429` with code `rate_limited` and a `Retry-After` header.

## How Cloud calls your service

- **HTTPS only.** Deployments must be `https://` URLs on the public internet. Private and internal
  addresses are refused.
- **Identity keys are required.** Your service must check the environment's identity key
  (`identityKeys` in `serve()` or `fetchHandler()`).
- **Request-response by default.** Each time a handler resumes is a new request. On serverless
  platforms the runtime sends the journal recorded so far with every resume; a long-running
  `serve()` keeps recent journals in memory, so a resume usually carries only what is new. Long
  journals and large step results still cost bytes: keep step results small. Each turn must finish within the [turn time limit](#turn-time-limit). Streaming
  needs `"transport": "declared"` and HTTP/2 all the way to your app; see
  [Deployments](/docs/cloud/deployments#transport).
- **No telemetry export from your handlers.** Spans and logs stay in the console; exporting them
  to your own OpenTelemetry collector is turned off on shared cells.

## No SLA

The Beta has no service level agreement and no uptime credit. Plan for interruptions.
