Zaroz
Units

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.

limitdefaultnotes
Units per Workloadthe product's maximum, 20 for the Workload productalso capped by your organization's limit and by your policy's own max_units
Total size of units per organization100 vCPU and 200 GiB of memoryeach unit counts at its own size; staff can raise it
Unit starts per hour, per organization600counted from pod starts; a flapping policy uses these up
Units with a shared volume1refused with volume_locks_to_one_unit
Spend on extra unitsyour spend_cap_cents, if setscaling refuses to grow at the cap
Public portsthe plan's included slots (none for a Workload) plus those you addport-limit when full
Log lines per second per container500the rest go to the archive, not away
Log and metric retention30 daysincludes scaled-away units
Search text200 characterssubstring, not a regular expression
Log page size2000 linesdefault 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.stopped reason memory_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_exit says 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:

JSONCode
{"key": "lobby-7", "resources": {"cpu": 0.5, "memory_mib": 512}}
rulevalue
smallest0.25 vCPU and 256 MiB
steps0.25 vCPU for CPU, 128 MiB for memory
largestthe plan's size
owner capmax_unit_resources on the scaling policy, if set
  • Leave resources out 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 fieldMeaning
ZAROZ_CPU_MILLICOREScpu_millicoresCPU the unit may use (2000 is two cores, 250 is a quarter of one)
ZAROZ_MEMORY_BUDGET_MIBmemory_budget_mibmemory the unit is held to, in MiB: its own size, or the plan's
ZAROZ_MEMORY_LIMIT_MIBmemory_limit_mibmemory at which the process is killed, in MiB
JSONCode
{"schema_version":1,"cpu_millicores":2000,"memory_budget_mib":4096,"memory_limit_mib":5120}

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):

TerminalCode
exec java -Xmx$((ZAROZ_MEMORY_BUDGET_MIB * 3 / 4))m -jar app.jar

Node.js:

JavascriptCode
import { readFileSync } from "node:fs"; const r = JSON.parse(readFileSync("/zaroz/resources.json", "utf8")); const heapMiB = Math.floor(r.memory_budget_mib * 0.75); // start the worker with: node --max-old-space-size=<heapMiB> server.js const cacheBytes = Math.floor(r.memory_budget_mib * 0.1) * 1024 * 1024; console.log({ heapMiB, cacheBytes, cpus: r.cpu_millicores / 1000 });

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.

Last modified on