
# Sizing and capacity

On a private target, services set `cpu` and `memory` in `agentcloud.toml`, within the owner's app cap and node size. `agc ship` checks the fit before building. A release that doesn't fit fails with `ship.over_cap` or `ship.no_room` and leaves production untouched; one that fits ends in `"outcome": "live"` with exit 0.

## Ask your agent

```text
Our app runs on our company's private target. Size its services in agentcloud.toml: give the web
service 1 CPU and 2Gi of memory and the worker 0.5 CPU and 1Gi, then run agc check and agc ship.
If the ship says the release is over the cap or there's no room, show me the message instead of
lowering the numbers on your own.
```

You'll see the release ship, or a message naming the numbers and who can raise the cap.

## Steps

```toml
[service.web]
cpu = 1
memory = "2Gi"

[service.worker]
command = "node worker.js"
instances = 2
cpu = 0.5
memory = "1Gi"
```

```bash
agc check
agc ship
```

An owner sets the cap and node size in the console: **Deployment targets** → the target's **Manage** → **App CPU cap**, **App memory cap**, **Node size**, then **Save**. The next ship is judged against them.

## How it works

Each instance requests what its service asks for. The memory limit equals the request, and there's no CPU limit, so pods aren't throttled; a pod that outgrows its memory request is killed rather than starving its neighbours. A service that sets neither key asks for 0.5 CPU and `1Gi`.

The **cap** is on an app's total: web × its instances plus worker × its instances. That's what the node pays for. Exceeding it is `ship.over_cap`.

The **fit** counts what is really on the node at once:

- every live app's requests, and each app's previous version for 10 minutes after a switch, until its prune is queued;
- a deleted app until a heartbeat after its deletion no longer lists its `app-<name>` namespace;
- for this release, the larger of the new version running beside the old one or the rehearsal's pods (web × 1, worker × 2, and two checker pods of 0.02 CPU and 64 MiB each), never both, because the runner places a version only once the app's rehearsal pods are gone and reports `rehearsals_cleared`.

The node's measure is the allocatable CPU and memory the runner reports in its heartbeat; before the first heartbeat it's the node size's nominal figure. The console shows both under **Capacity**. Exceeding it is `ship.no_room`. The message names each of your organization's apps it counted with its CPU and memory; on a shared target, other organizations' apps are one sum, never named.

A pod runs on one node, so each pod must also fit one node's room. A pod larger than any node is `ship.no_node`; lower that service's `cpu` or `memory`. When the pool has room in all but no single node does, `ship.no_room` names the largest size that fits now, like `cpu = 1, memory = "2Gi"`.

`ship.no_room` never asks the app to shrink. The node's real size is the stack's instance type, so adding room is a stack change made with Agent Cloud and your infra team, not a console setting. The console's **Node size** only stands in until the node reports.

## Reference

| Setting | Where | Default | Allowed |
|---|---|---|---|
| `cpu` | `[service.web]`, `[service.worker]` | 0.5 | 0.1 to 64 |
| `memory` | `[service.web]`, `[service.worker]` | `"1Gi"` | `"64Mi"` to `"256Gi"`, like `"512Mi"` or `"4Gi"` |
| `instances` | `[service.worker]` | 1 | 1 to 4 |
| App CPU cap | Console | 2 | 0.1 to 64 |
| App memory cap | Console | `4Gi` | like `4Gi` or `512Mi`, at least `64Mi` |
| Node size | Console | `m7i.2xlarge` | below |

| Node size | Nominal CPUs | Nominal memory |
|---|---|---|
| `m7i.large` | 2 | 8 GiB |
| `m7i.xlarge` | 4 | 16 GiB |
| `m7i.2xlarge` | 8 | 32 GiB |
| `m7i.4xlarge` | 16 | 64 GiB |

The node also runs k3s, Traefik, the runner (50m CPU, 96Mi requested) and the egress proxy (50m, 64Mi), so allocatable is a little under nominal.

## Errors

| code | exit | cause | fix |
|---|---|---|---|
| `ship.over_cap` | 1 | The release's total is over the target's app cap | Lower `cpu` or `memory`, or ask an owner to raise the cap in **Deployment targets** |
| `ship.no_room` | 1 | The node can't hold this release beside what's already there | Ask Agent Cloud for room with `agc feedback`; the node is resized with your infra team |
| `ship.no_node` | 1 | One pod is larger than any node's room | Lower that service's `cpu` or `memory` |
| `ship.bad_resources` | 1 | `cpu` or `memory` is malformed or out of range | Fix the value in `agentcloud.toml` |

A failing example: the worker above, the web service raised to `cpu = 2` and `memory = "4Gi"`, and the default cap of 2 CPU and `4Gi`.

```json
{
  "ok": false,
  "product": "agent.cloud",
  "command": "ship",
  "error": {
    "retryable": false,
    "code": "ship.over_cap",
    "message": "This release asks for 3 CPU and 6 GiB in all (web × 1, worker × 2); the organization allows an app 2 CPU and 4 GiB on this target. Nothing was built.",
    "fix": "Lower cpu or memory in agentcloud.toml, or ask owner@example.test to raise the app cap for Staging in the console's Deployment targets, then ship again."
  },
  "next": [{ "cmd": "agc status", "why": "see the current state before retrying" }]
}
```

## Limits

- Node sizes: the four above.
- The previous version is counted for 10 minutes after each switch.

## Agent notes

- `ship.no_room` and `ship.over_cap` aren't retryable by shipping again. Report the message to the person; don't shrink `memory` below what the app needs to make it fit.
- On Agent Cloud's own servers the same keys apply within Agent Cloud's own per-app ceiling, not the target's cap.
- A console change to an app's instances is measured at the next ship, so ship after changing it to confirm it fits.
- On manifests version 9 or later, `agc status` shows each service's memory in use against its limit; use it to size `memory` from real numbers.

## Related

- [Architecture of a private target](/docs/targets/architecture-of-a-private-target.md)
- [agentcloud.toml reference](/docs/reference/agentcloud-toml-reference.md)
- [Deployment targets (owner view)](/docs/owners/deployment-targets.md)
- [Limits and quotas](/docs/reference/limits-and-quotas.md)

<!-- feedback:start -->
---
Wrong, outdated or unclear? Run `agc feedback docs "targets/sizing-and-capacity: <what is wrong>" --body <file>` with the sentence quoted in the file. No code or app data is sent.
<!-- feedback:end -->
