Limits
Limits keep one mistake from becoming a large bill, and keep the shared platform fair. Reaching a limit never stops a unit that is already running. The request that would exceed it is refused or recorded, with the reason.
The figures below are the launch defaults. Your Workload's own ceilings are in the API: max_units, included_units and organization_limits in GET .../units.
| limit | default | notes |
|---|---|---|
| Units per Workload | the product's maximum, 20 for the Workload product | also capped by your organization's limit and by your policy's own max_units |
| Total size of units per organization | 100 vCPU and 200 GiB of memory | each unit counts at its own size; staff can raise it |
| Unit starts per hour, per organization | 600 | counted from pod starts; a flapping policy uses these up |
| Units with a shared volume | 1 | refused with volume_locks_to_one_unit |
| Spend on extra units | your spend_cap_cents, if set | scaling refuses to grow at the cap |
| Public ports | the plan's included slots (none for a Workload) plus those you add | port-limit when full |
| Log lines per second per container | 500 | the rest go to the archive, not away |
| Log and metric retention | 30 days | includes scaled-away units |
| Search text | 200 characters | substring, not a regular expression |
| Log page size | 2000 lines | default 500 |
Memory
Every unit has a memory budget: the memory its plan includes, or the memory of its own size if you gave it one (see Unit sizes). Each unit is held to its own budget, and units are never added together.
- Going over the budget briefly is fine. The container has headroom above it, the limit.
- Staying over the budget stops the unit, and the owner is notified. Memory is read every few seconds. A unit more than 10% over its budget on two readings in a row (about 10 seconds) is stopped. A unit over its budget by less than that is stopped after about a minute. Coming back under the budget resets both counts.
- A unit of a code-mode Workload (one your program created, or a warm unit) is stopped alone, with
unit.stoppedreasonmemory_limit. The other units keep running. If the Workload already holds its 1,000 stopped units, the unit is destroyed instead of stopped. - In a fixed or autoscaled policy the units are copies of one another, so the whole Workload stops.
- At the limit itself the process is killed (out of memory) at once, and the unit restarts if its
on_exitsays so.
Metrics show memory against the budget; see Logs and metrics. Your orchestrator can read the reason from the event: Units your code controls.
Unit sizes
A unit your code creates can be smaller than the plan. Pass resources when you create it:
Code
| rule | value |
|---|---|
| smallest | 0.25 vCPU and 256 MiB |
| steps | 0.25 vCPU for CPU, 128 MiB for memory |
| largest | the plan's size |
| owner cap | max_unit_resources on the scaling policy, if set |
- Leave
resourcesout and the unit gets the largest size allowed: the plan's, or the cap when it is lower. - A size above the plan is refused with
400 unit-size-above-plan. Above the cap,400 unit-size-above-cap. Off the steps or under the smallest,400 invalid-unit-size. Nothing is created by a refused call. The codes are in Errors. - A unit keeps its size for life. Creating a live key again with another size answers
409 unit-size-differs. To change a size, destroy the unit and create it again. - Each unit is held to its own memory (see Memory), so a quarter-size unit that uses more than its 256 MiB is stopped like any other.
Reading a unit shows resources (cpu in vCPU, memory_mib) and own_size, which is true when the size is the unit's own and false when it is the plan's. How a smaller unit is billed is on Billing.
The organization limit counts size, not units: the total vCPU and memory of the units that hold a slot, each at its own size or the plan's. Fifty quarter-size units use much less of it than fifty plans. organization_limits in GET .../units shows cpu_millicores and memory_mib, each with current, limit and level.
Sizing your process
Every unit gets its numbers in the environment of its main container and in a file, so a runtime can size itself. This holds for every unit, whatever its mode, with or without the unit agent. All memory figures are in MiB.
| Environment variable | /zaroz/resources.json field | Meaning |
|---|---|---|
ZAROZ_CPU_MILLICORES | cpu_millicores | CPU the unit may use (2000 is two cores, 250 is a quarter of one) |
ZAROZ_MEMORY_BUDGET_MIB | memory_budget_mib | memory the unit is held to, in MiB: its own size, or the plan's |
ZAROZ_MEMORY_LIMIT_MIB | memory_limit_mib | memory at which the process is killed, in MiB |
Code
For a unit with a size of its own the numbers are the unit's, not the plan's. A unit of 0.25 vCPU and 256 MiB reads 250 and 256. Its container's CPU limit is written in millicores (250m).
The limit is the budget plus 1024 MiB for a budget of 1 GiB or more. Below 1 GiB it is the budget plus a quarter of it, at least 64 MiB more (a 512 MiB budget has a 640 MiB limit).
Size heaps and caches from the budget, with room for non-heap memory, not from the limit: a process that lives near the limit stays over the budget and is stopped. The file's JSON Schema is resources.schema.json. The numbers are fixed for the life of the unit's pod, so read them once at start. Units created before this release get the variables and the file the next time they start.
Java (heap about 75% of the budget):
Code
Node.js:
Code
What a refusal looks like
A scaling refusal is recorded as a decision with a reason (org_limit, spend_cap, no_capacity, at_max), so you can see it on the unit-count chart rather than wonder why the count did not move. A refused policy update returns the reason in details, with a reason code before the colon, and a policy that cannot be saved because of a limit is not partly applied.
no_capacity means the platform had no room to place another unit in your region right now. It is not your limit; the evaluator tries again on its next pass.
Raising a limit
Open a support ticket and say which limit and why. Staff can raise the per-organization limits.
