Scaling and the performance governor¶
Two different things limit how much work runs. A project's replica count decides how many runtime pods serve it, and the control plane decides that count within bounds you set. A node's own intake decides how many assignments it pulls and works on at once, and the node's performance governor lowers that intake as the node fills. This page covers how a replica count is decided and applied, and how the governor sets the node's limits each cycle.
Who decides what¶
flowchart TB
subgraph CP["CONTROL PLANE"]
direction TB
POL[("Scaling state per project<br/>min, max, target_queue_depth,<br/>cooldown_period, manual lock")]
DR{{"desired_replicas"}}
POL --> DR
end
subgraph NODE["NODE"]
direction TB
ACT["Runtime actuator"]
GOV{{"Performance governor<br/>max_pull, max_workers, flush gates"}}
SIG[("Queue, runtime slots,<br/>outbox backlog")]
SIG --> GOV
end
DEP["Project Deployment<br/>replicas"]
OP["xratu scale"]
RUN["A run for a version<br/>at zero replicas"]
OP --> POL
RUN -->|"wake"| DR
DR -->|"serve_start with desired_replicas"| ACT
ACT ==> DEP
GOV -->|"limits the next pull<br/>and worker phase"| NODE
The replica count is a control plane decision, carried to the node in the
runtime deploy contract and applied as the Deployment's replicas. The
governor is local to the node and limits only the node's own intake.
A project's replica count¶
The control plane keeps one scaling state per project. Its bounds start from
the scaling block in deploy.xratu and are changed with xratu scale:
PROJECT=support-agent
xratu scale "$PROJECT" --min-replicas 1 --max-replicas 4 \
--target-queue-depth 10 --cooldown-period 300s --reason "raise ceiling for launch"
desired_replicas is always held within min_replicas and max_replicas. A
manual lock pins it to a fixed count, still within the bounds, until unlocked:
xratu scale "$PROJECT" --lock --replicas 2 --reason "pin during incident"
xratu scale "$PROJECT" --unlock --reason "incident closed"
Every change is recorded as a scaling decision with its reason and actor.
Lowering the ceiling under load is refused. When the project's dispatch
queue is above its lag objective (30 seconds at the 95th percentile by
default), a change that lowers max_replicas is refused with HTTP 409:
{"code": "SCALING_LAG_GUARDRAIL_BLOCKED", "message": "cannot reduce max_replicas while queue lag SLO is breached"}
A version at zero replicas wakes on demand. A run for a version with no
running replicas sets desired_replicas to its wake target (the desired
count, at least 1, within the bounds, or the locked count) and issues
serve_start with reason run_wake_requested. The scaling state's
cold_start_phase moves from IDLE_ZERO to WAKE_PENDING. A version already
starting or running at the wake target is left as it is, and a wake target of
0 blocks the run.
Applying the count on the node¶
The node applies desired_replicas from the runtime deploy contract as the
Deployment's replicas on the next serve_start, and the rollout follows the
contract's maxUnavailable and maxSurge. The contract's min_replicas,
max_replicas, target_queue_depth and cooldown_period are repeated in
the deploy evidence, so a report shows the bounds the count was chosen within.
While the scaling state is unlocked, the control plane moves desired_replicas
within the bounds to keep the project's queued work per replica near
target_queue_depth, and waits cooldown_period between changes. Each change
reaches the node as a new serve_start. A manual lock holds the count until it
is unlocked. See
Runtime actuation.
The performance governor¶
Every cycle, before it pulls, the node's performance governor reads four pressures and sets the cycle's limits:
queue ratio local queue depth / queue high watermark
runtime ratio active runtimes / max_worker_slots
pressure ratio the larger of the two
outbox pending reports waiting in the telemetry outbox
Pull. The node stops pulling (max_pull 0) when the queue is flagged or
at its watermark, every runtime slot is in use, or the outbox holds 5,000 or
more pending records. Otherwise it pulls up to its configured
max_assignments_per_pull, halved at a pressure ratio of 0.65 and quartered at
0.85, never below 1.
Workers. max_workers is the free worker capacity, cut to three quarters
when the runtime ratio reaches 0.75 and to half at 0.90, never below 1 while
any capacity is free.
Flush. Status and events are always flushed. Logs are held back while the node is under backpressure, the queue ratio is at 0.90 or above, or the outbox holds 2,000 or more pending records, so status reports and events reach the control plane first when the node is loaded.
The worker phase uses the smallest of the governor's bound, the free capacity and the queue depth. See Cycle orchestration.
Reading the governor's decision¶
The decision is reported as xratud.performance_governor.v1 in the cycle
summary, and its backpressure flag, reason and limits in the heartbeat's
governor:
{
"contract_version": "xratud.performance_governor.v1",
"backpressure": false,
"reason": "medium_pressure_scaled_down",
"pressure_ratio": 0.71875,
"limits": {"max_pull": 2, "max_workers": 9, "flush_status": 1, "flush_events": 1, "flush_logs": 1},
"snapshot": {
"queue_depth": 230, "queue_high_watermark": 1000,
"runtime_active_count": 23, "runtime_max_active": 32,
"capacity_available": 9, "outbox_pending": 140
}
}
reason |
Condition |
|---|---|
normal |
Pressure ratio below 0.65 |
medium_pressure_scaled_down |
Pressure ratio from 0.65 |
high_pressure_scaled_down |
Pressure ratio from 0.85 |
queue_backpressure |
Pulling stopped: the queue is flagged or at its watermark |
runtime_capacity_exhausted |
Pulling stopped: every runtime slot is in use |
outbox_hard_backlog |
Pulling stopped: 5,000 or more reports are waiting to be delivered |
A node reporting outbox_hard_backlog stops taking work until the control
plane accepts its backlog; check the node's connection to the control plane
before its capacity. See
Telemetry under degradation.