Scale AI queue workers on ready backlog per replica when eligible work is waiting and adding workers increases completed work. Use CPU if it is the limiting resource and changes reliably with the backlog. Treat oldest eligible job age as evidence about waiting time and deadlines. When more workers produce more throttling at a shared provider while completions stay flat, hold further scale-up and address the limit. Horizontal Pod Autoscaling
TL;DR. Measure the count of jobs eligible to be claimed, the age of the oldest eligible job, and the rate of completed jobs. For a Kubernetes external backlog metric with an
AverageValuetarget, publish the total for one worker pool once and let the HPA compare that with the per-replica target. Confirm the adapter reading and controller recommendation on a known queue count. Keep the change only when more usable capacity arrives in time and actually reduces waiting without increasing blocked or failed work.
| Observation | Candidate action | What to verify before adopting it |
|---|---|---|
| CPU rises with queueing, and more workers raise completed throughput | Try CPU utilization | Queue age improves under the same workload |
| Ready work grows while worker CPU stays low and the downstream service has capacity | Try eligible backlog per replica | The adapter delivers the total once, and real completions rise |
| A small set of ready jobs stays old while the rest drain | Inspect those jobs and their worker pool | They are claimable, have an eligible worker, and share the reported queue |
| Provider throttling rises while completed jobs stay flat | Hold further scale-up in the trial | Compare concurrency, quotas, and retries at the shared dependency |
| Metric stops updating | Distinguish missing or stale data from a fresh zero | Verify alarm, controller status, and behavior at the selected fallback |
Identify the part of the wait a new worker can change
The useful question is whether another worker will increase successful completions before jobs exceed their wait target. A total queue depth, a busy CPU graph, and a controller recommendation observe different parts of that question. A scale-up might bring more Pods into the scheduler, yet those Pods could spend most of their first few minutes loading a model. Extra callers could compete for a fixed upstream allowance. An early increase in queue claim rate could simply move jobs from ready to running while none finish. Include completion results and job age in the test from the start.
Draw a timeline for one job. Record submitted time, time it first becomes eligible, claim time, the time the worker begins useful work, the time a provider request is admitted if applicable, and completion time. If a retry makes the job temporarily ineligible, capture that transition and its retry policy separately. Identities and stages matter because queueing time, worker initialization, provider admission and actual model processing suggest different interventions. The absolute delay may look identical on a customer dashboard.
Start by comparing two representative periods. Choose one where ready work rises and eligible age starts moving. Choose another with similar arrival mix but lower wait. In each period, observe active matching workers, ready jobs, queued age, completion rate, and provider limits. Write down which stage explains the difference and what result would overturn that explanation. If CPU is flat because workers are blocked on an external quota, adding another identical worker should raise upstream competition more readily than completed throughput. If a local concurrency limit is the bottleneck and the provider has capacity, the same worker addition should consume backlog faster.
Use a bounded worker addition to separate those explanations in staging or within a separately approved live canary. Keep the job mix, deadlines, provider quota, and retry settings comparable. Compare per-minute completion and oldest age before and after useful capacity becomes available. Register the readiness timestamp for each added worker. If you had four desired replicas during most of the measurement but only two accepting work, explain the gap before using the result to tune an autoscaler. The sinc-LLM latency guide shows how to identify a bottleneck beyond queueing.
Define what counts as eligible backlog
A queue can hold many items that cannot run right now. A delayed retry with a future availability timestamp, an item awaiting human review, an active lease, or a job routed to a different model pool should not silently count as available work for the worker you want to scale. Give the metric an explicit definition. A useful definition might be “the count of runnable document classification jobs in pool west whose scheduled start is at or before observation time, with no active claim.” Use the queue’s own semantics for availability and claims. A monitoring label alone does not make an item runnable.
Write eligibility together with the queue owner and the team that reads the signal. Make the source responsible for selectivity visible. If runnable status is derived from state plus timestamps, run a small test that transitions one named item from waiting to ready and back out of ready when claimed. The total and age should change according to the intentional rule, even when the database has other records. If the measurement source reports only a per-broker count, determine whether those counts describe distinct partitions, a replicated total, or a sampled estimate. Adding replicated totals produces a multiplier that looks like sudden demand.
Define age on the same population. Oldest ready age is elapsed time since the oldest currently eligible item became available. It is often distinct from time since a customer submitted work, because scheduling or delayed retries can change eligibility time. Keep customer age if you have a service objective that includes those periods. Consider also recording the age distribution, how many jobs are near their due time, and the age of completed jobs from the same cohort. The maximum is a useful early warning, but one stuck item can dominate it. A system-wide scale decision requires evidence that another worker can help that item or the wider workload.
Use durable identifiers or known staging input lists for spot checks. When you inject a test case, record how many items are ready, delayed, completed, leased, and intentionally excluded. For example, a synthetic queue contains one hundred twenty entries, of which seventy are ready in the selected worker pool, twenty have a future retry, ten have a valid claim, and twenty belong to a separate pool. A metric contract for this pool expects seventy, not one hundred twenty. If one eligible item is claimed and a delayed job becomes ready in the same interval, the total may remain steady even though two transitions occurred. Read item-level state when proving the metric’s definition.
For mixed workloads, inspect what a job count implies. Twenty fast classifications and twenty long summarization jobs need not represent the same worker time. Separate pools can make the capacity relationship easier to validate when resource classes materially differ. Another option is a work estimate per job class, expressed in a meaningful unit such as expected worker seconds or other per-job cost. Confirm that estimate against real staging completion and scarcity costs. If the estimator ranks easy requests as hard or reacts slowly when the request mix changes, a simple scoped count plus age can be more transparent.
Compare signals against the same operating decision
CPU utilization is a plausible first signal when workers compete for CPU, jobs consume predictable CPU while active, and increasing the deployment can add CPU resources. In a Kubernetes HPA CPU utilization configuration, resource requests are part of the calculation. A container missing relevant requests can leave utilization undefined for the affected metric. Make sure CPU charts use the same population and unit as the controller. A chart of raw CPU usage may look active without matching a request-based utilization target. If a non-worker sidecar contributes materially, check which resource or container metric the running Kubernetes release supports. Kubernetes HPA support for resource and container metrics
Backlog is an intuitively useful measure when workers spend substantial time waiting for network or accelerator slots and CPU gives little signal before queueing is noticeable. It points directly at unstarted eligible work. It can be misleading when eligibility is incorrectly measured or provider limits leave no spare capacity. Confirm that more workers actually help the population counted by the backlog, rather than starting an identical pool that competes at the same bottleneck. If the system schedules work very unevenly because jobs are pinned to models or hardware, inspect backlog at that boundary.
Age and deadlines can move the operator to action sooner than depth. Five jobs can be an incident if they have been waiting for minutes against a short expectation. A much larger overnight batch can be fine if the target is completion by the next morning. Age is usually most informative when joined to a specific eligible class and deadline. Using raw age by itself as an HPA signal can make a single permanently stalled item repeatedly demand more workers. Use it with eligibility and service observations. Decide in advance whether age is a scale input, a release acceptance metric, or an alert that directs someone to inspect delayed work.
Some queues are constrained by concurrency rather than host CPU or raw backlog. If each worker handles a fixed number of concurrent tasks and can hold a lot of time waiting on a model request, busy execution slots and completion rates can establish the mechanism. Verify the maximum independently of the replica count. A pool of four Pods can expose forty configured slots, yet one provider account may admit only some of them. Raising per-worker concurrency and raising replicas are different changes when they share the same provider account, rate limits or network bandwidth. Select the smallest trial that isolates the proposed mechanism.
Shared capacity limits deserve a separate line in the decision. Record admitted provider calls, throttles, backoff, retries, model queue delay and successful business completions. Aim to reduce work waiting at the customer boundary. Consider a synthetic workload where two workers together complete eight jobs per minute. When four workers complete sixteen jobs per minute and errors remain stable, there is evidence for additive capacity in those conditions. When four workers complete only eight jobs per minute but generate more throttles, replica count has changed without helping the queue. A different dependency, reduced demand, routing adjustment or concurrency policy may be what changes the outcome.
Write the metric contract before connecting the controller
Give the metric a name and describe its value in words. Include the population, unit, raw total or average, selector, sample timestamp, and behavior if data is unavailable. Name the source read you trust. For one worker pool an example contract reads: “Ready backlog, jobs. Total currently runnable document classification jobs for production pool west, observed at the queue, excluding active claims and delayed retry. Report the raw total for the selected scope once. A valid current zero means no eligible jobs. Missing or stale samples cannot be reported as a new zero.”
Record which dimension selects the queue. In multi-tenant or multi-model systems, a metric name alone may describe several different series. Provide the HPA metric selector and compare the adapter response against the intended queue and namespace. Some adapters aggregate query results, and some select or transform labels. Inspect the actual external metrics API response instead of inferring aggregation behavior from the graph or metric label. In an isolated staging fixture, keep one selected queue and one excluded queue with different counts. Changing the excluded queue must leave the selected reading unchanged.
Choose a separate observation timestamp that survives aggregation. The time a dashboard drew one sample may differ from the time the queue was actually observed. If possible, retain both the originating measurement timestamp and the adapter request time. Compare original queue count and adapter value within the same observation window and mark scrape skew when relevant. If the adapter republishes a last-known number with a fresh receipt timestamp, determine whether users can still see the older observation. An unchanged value can be healthy for a steady queue, so freshness needs its own observed age or replay-control fixture.
Write down when to distrust a count. If a partition fails to publish but the aggregator sums the rest, the resulting number can be both recent and incomplete. Require the expected partition or shard population, especially when each partition has its own workers. A synthetic test with one deliberately unavailable partition distinguishes a clean zero from a partial result. Decide whether the adapter should withhold the combined metric, report a degraded indicator or allow a bounded fallback. Then observe what the HPA and alert path do. Do not assume that every consumer interprets a special missing value in the same way.
Calculate the expected recommendation twice
A Kubernetes HPA compares observed metric values with targets while working within configured replica limits and controller behavior. The basic algorithm uses a ratio of the current metric value to the desired value, with a rounded-up replica recommendation. With an external metric using AverageValue, start with the total for the intended worker pool so the controller can make the per-replica comparison. Value and AverageValue express different target semantics. Trace the exact specification in autoscaling/v2 and the metric type already present before applying the formula. Kubernetes HPA basic algorithm · HorizontalPodAutoscaler v2 reference
In a synthetic fixture, use two current replicas, three hundred sixty ready jobs, and a target of ninety ready jobs per replica. The displayed current average is one hundred eighty jobs per replica. Divide that by the target of ninety to get a ratio of two. Multiply the two replicas by that ratio and round up, giving four. In the simplified steady example you can independently divide the total three hundred sixty jobs by the target ninety jobs per replica and get four. The arithmetic is a test oracle under the fixture assumptions. Actual stabilization, timing, tolerance, and bounds can affect the applied replica count.
Now intentionally publish the already-divided value of one hundred eighty into the same test adapter path. With the same two current replicas, the controller’s per-replica comparison sees ninety, and the simplified recommendation becomes two. This is the adverse case the normal test should catch. If the runner sees the same displayed recommendation for correct and incorrect readings, check for an overly restrictive maximum, scale-up policy, wrong metric selector, or a result window where the controller did not process both samples. Use a fixture that can actually discriminate between the two predictions.
| Measure | Correct adapter scope and unit | Deliberately divided adapter value |
|---|---|---|
| Raw selected queue backlog | 360 jobs | 360 jobs |
| Adapter reports | 360 jobs | 180 jobs |
| Replica basis in the simplified fixture | 2 | 2 |
| Current average at controller comparison | 180 jobs per replica | 90 jobs per replica |
| Target average | 90 jobs per replica | 90 jobs per replica |
| Simplified recommendation before applied limits | 4 replicas | 2 replicas |
Add a rounding case. With three hundred sixty-one eligible jobs and a target of ninety jobs per replica, four replicas correspond to capacity for a target average of ninety jobs each and leave one extra job in the aggregate comparison. Dividing the total by ninety gives slightly more than four, so the simplified ratio calculation rounds up to five. If you test a deployed controller and observe four, inspect the configured tolerance and actual metrics, rather than reporting the cluster violates the formula. Choose a deliberately wider difference when the purpose is to verify that the scaler can recognize a direction. A near-boundary example is best used to teach why the simplified comparison alone does not tell you what the controller will apply.
Keep a small acceptance table with input total, adapter response, metric target, relevant replica observations, expected recommendation, observed recommendation, and applicable policy. When a reported HPA status field summarizes the metric, read the current deployment state and HPA conditions alongside it. Kubernetes documents that adjustments for missing or unready Pod metrics can affect calculations while a reported average still reflects the original metric. The significance depends on the metric type and running release. Record both values with their meanings. HPA concepts and algorithm details
Translate a replica change into useful capacity
A backlog rule affects desired replicas. A worker only helps after it is scheduled, starts, warms any model it owns, and can claim and complete work. Estimate what that delay means in your queue. Start a representative staging burst with the baseline warm capacity. Time from observed pressure to a controller change, from change to the first new ready Pod, and from readiness to the first new completed job. Use these stages to answer whether the queue needs more warm minimum capacity or a faster initialization path before tuning the target.
Use a simple drain calculation as a hypothesis. In an illustrative interval, a backlog of one hundred twenty eligible jobs receives six new jobs per minute. If completed work sustains eighteen jobs per minute with the larger pool, net drain is twelve jobs per minute, and the original backlog can clear in approximately ten minutes after that throughput becomes available, assuming the arrival and completion rates hold. If completions are eight per minute under provider throttling, net drain is two per minute and the same calculation gives about sixty minutes. These calculations use steady rates and omit startup, retries, mix changes and deadlines. Test the actual queue history and age instead of promising either duration to customers.
Look at goodput as well as gross work. If a new Pod family claims tasks rapidly but times out, the apparent ready backlog may shrink while success rate falls and delayed retries accumulate. Pair the queue view with completions counted once per job and a view of terminal failure or repeated attempts. When the business workflow can partially succeed, use the authoritative outcome you care about rather than treating a worker acknowledgment as complete service. A job can be acknowledged in the queue while a later persistence step still fails.
For long startup times, use a known staging model generation and a positive capacity control. One option is to keep a ready baseline worker, then scale a candidate pool while checking that new workers accept tasks only once their intended model is loaded. Compare how many were requested, how many became ready, how many claimed eligible work, and how many completed. A short observation window might show no improvement because model loading still occupies all new Pods. An extended trial with an observed completion from a new Pod separates ramp delay from a hard capacity limit. sinc-LLM’s model worker readiness guide
Make missing data and a fresh zero disagree on purpose
A healthy empty queue and an unavailable queue metric should appear differently in operations. Exercise both. First let the test queue drain while the collection path is healthy. Verify a recent raw zero, corresponding adapter response, report timestamp and the expected controller behavior within its limits. Then leave runnable work pending and interrupt one collection boundary in the staging harness. The queue source can still prove work remains even though the adapter no longer reports it. Check whether the controller status, alarms and any fallback distinguish the cases on the actual deployment.
Test partial freshness. Keep one shard responding and pause another. Change only the silent shard’s known fixture count while the aggregate still emits values. If your observability path is correct, an operator can see that the scope is incomplete. If the aggregate quietly drops that shard and reports a plausible low total, replica behavior based on that value needs a correction. Set a freshness boundary based on the queue and provider's actual collection rhythm, and record why a late measurement changes the decision. Terms such as current or recent need a measured interval and an owner on a real on-call page.
Multiple configured metrics can affect the expected result when one is unavailable. Kubernetes documents that HPA evaluates each specified metric and uses the largest desired replica count. When a metric cannot be evaluated and others indicate a scale-down, the HPA can skip the scale-down; another valid metric can still trigger a scale-up. Check this specifically if your HPA combines external backlog with resource utilization. Treat single-metric failure and partial multi-metric results as separate cases. Inspect the exact controller behavior for the version, policies and installation you actually use. Kubernetes scaling on multiple metrics
Avoid making a test pass by depending on CPU fallback without ever showing it is valid. In a mixed policy, change the external metric separately from CPU and observe each recommendation under controlled demand. A spiking sidecar, missing resource request, or isolated failed node can make CPU an unreliable backup. The staging decision should say what you expect when each input is absent, what minimum capacity remains, and which alarm is routed to an operator. Silence during metric loss is a finding even when replicas happen to stay at a tolerable number.
Record the pool selector, sample time, contributing shard count, adapter reading, recommendation, and desired replicas on the same timeline. In the stale-data trial, keep the fixture's runnable jobs present and check that the controller does not reduce replicas on the strength of a stale or incomplete backlog reading. If the adapter still serves an old sample as a valid low value, hold the release until the metric contract exposes its age or the controller rejects the unsafe recommendation.
Run the release trial with a comparison that matters
Freeze the backlog definition, HPA target, replica bounds, worker build, allowed model endpoint, rate limits, start conditions, and two matching demand windows before beginning. You need a representative burst and an adverse fixture, not an artificial stress run that changes every dependency at once. The old policy and candidate policy should receive equivalent submissions and eligibility timing as far as the staging harness can arrange. Mark the source of experimental variation. For training or evaluation queues that do not allow equivalent repeated inference, capture their key constrained resources and use a safe representative workload with the scope stated.
Record observations at intervals short enough to place changes in order. Start with raw ready count and oldest eligible age, then capture adapter value, observation timestamp, HPA recommendation and conditions, desired and ready replicas, job completion and accrued cost. Record whether added workers started serving before the useful deadline. Keep the denominator visible for rates, including job count and the time window. A single minute with near-zero arrivals may demonstrate nothing about a desired release burst even if a chart shows improvement. Retain the measurement window and any adverse findings instead of averaging them out.
| Trial check | Independent evidence | Hold condition |
|---|---|---|
| Metric units and selector | Authoritative ready count and actual adapter reading for the selected pool | Values differ after accounting for a known observation delay |
| Timing | Desired Pod time, ready time, and first attributable completion | Added capacity arrives too late for the waiting workload |
| Effect on users | Same workload comparison on age, successful completions and failures | More replicas fail to improve the target or materially worsen losses |
| Dependency ceiling | Provider admissions, throttles, retries and useful results | More callers intensify the bottleneck without increasing goodput |
| Signal loss | Fresh zero contrasted with outage, stale sample and partial partition | Controller or alert path cannot distinguish missing data from empty work |
| Bounded resource use | Chosen maximum, provider limits, and trial cost or usage | The result depends on unapproved or unavailable capacity |
Test scale-down separately. Start a representative workload with some jobs already running and allow ready backlog to approach zero. In many systems the metric legitimately falls to zero before all active jobs finish. Verify the worker shutdown, claim renewal, and completion semantics for work that outlives an admission change. Stabilization and policies help shape replica changes, while application behavior must preserve jobs during termination. An adverse case with a longer-than-normal in-flight job can catch a policy whose metric looks healthy while active work is repeatedly lost or retried. Observe the queue’s final outcome for that job.
End the trial with a written result that answers the decision. A useful statement might say that the selected pool's external metric matched the source, four ready workers reduced oldest eligible age on the staged burst, and that the documented missing-data condition was observed. Include the workload, exact policy, provider limits and safe fallback so a later operator can reproduce the test. If the desired replica increase is the only observed advantage, keep the new rule provisional and investigate the unresolved downstream mechanism. If the right decision differs by workload, name the scope instead of assigning the result to all teams’ queues.
An operator worksheet for the next queue
Keep one row per experiment and one row per adverse input. Before running it, record the owner of the queue definition, worker deployment and metrics adapter. Specify whether a queue item belongs to the test set and when its eligibility changes. Keep a list of distinct job IDs with expected stage transitions. Identify the count from the source and the connector evidence that represents the same sample. Add the work slice or tenant label if it changes how jobs are routed. An observer should be able to tell whether a hundred queued items represent this worker pool or some other pool.
Add one prediction about delivery and one about potential harm. For example, within the safe test bounds, more ready workers should increase successful completed jobs per minute and shorten oldest ready age. A rival result would be rising provider throttling and flat successful throughput. State which outcome favors each explanation. Set the trial’s observation length from the relevant startup and queue behavior, with an explicit stop rule for unexpectedly costly retries. Use a status such as unresolved if the data never reached the required boundary.
Save the exact HPA name and configuration, current replica observations, metric target and type, selected workload, and any separate warm capacity. If the metric changes shape but keeps its name, update the operator view and test the retained release policy. If the fleet caps or provider limits change, rerun the comparison in the new conditions. Evidence earned under previously unconstrained provider capacity no longer establishes an improvement once the account starts enforcing a tighter shared limit. Keep the arithmetic control available any time a reporting adapter changes.
A focused first step is to run the raw-total and deliberate double-division comparison on one staging pool with known counts. Check whether the intended scale recommendation differs, then add a sustained burst and read successful completions and queue age. As soon as you see a provider ceiling or an ambiguous missing-data state, track that condition as a separate decision. This keeps a metering bug, a capacity limit and an unreliable metric out of the same undifferentiated tuning pass.
Check whether the worker can help the waiting partition
Suppose your AI jobs specify a model revision and a region. There are two pools because only one can serve the regulated model. In a synthetic observation, the first pool has eighty eligible jobs and two ready workers. The second has twenty eligible jobs and four ready workers. A fleet total of one hundred jobs divided among six workers comes to about seventeen jobs per worker. The two scope-aligned readings are forty per worker in the first pool and five in the second. An aggregate target of twenty could look healthy even while the first pool exceeds it by a factor of two. This example assumes that workers cannot cross the pool boundary during the measurement.
Test the scope by adding ten ready jobs to the first partition while leaving the second unchanged. The first reading should rise from eighty to ninety. The second should remain twenty. Compare the scope in the collector query, the adapter metric response, and the scaler selector. Now make a worker from the second pool attempt a permitted staging claim. It should find only work that meets its eligibility rules. Read that claim from the queue's durable record. The assignment policy is part of the evidence for whether those apparently idle workers could ever help the older jobs.
A differently configured system could allow shared workers to serve multiple pools. Then a worker count grouped by the first label alone could understate usable capacity. Capture which jobs each worker can actually claim and whether a worker switches pools without reloading a large model. A temporary model allocation, burst policy or priority rule can make nominal sharing much smaller than the capacity a queue can use right now. Trace the observed claim and completion behavior before deciding whether to scale a dedicated deployment or rebalance a shared one.
Include a failure mode where a routing label changes during rollout. Write down the required selector on both old and new workers, and run the same scoped count fixture after the label change. If the adapter puts two names on the same queue and sums both, the stage will measure two copies of demand. If the new pool stopped matching the selector altogether, a low metric could coexist with a growing backlog. In either case fix the mapping at the first divergent boundary. Recalculate the scale decision after the measurement represents the intended scope again.
When reviewing production usage, compare collection timestamps and policy versions across these observations. Eighty jobs from the queue before deployment and ninety from the adapter afterward might simply describe different moments. A meaningful partition control uses a controlled input or a consistent snapshot, logs which queue changed, and states what traffic was expected at each worker. Keep the measurements beside the decision so the next operator can tell whether a new imbalance reflects real demand, changing access rules or a misleading aggregate.
FAQ
Should every AI queue scale on backlog?
Backlog helps when it counts eligible jobs and additional workers increase useful completion in the relevant timeframe. A CPU-constrained workload with a clear utilization signal might be better served by CPU. A queue blocked behind a common quota needs evidence that more replicas help before it adopts a backlog controller. Start with the mechanism and a matched trial, then choose the signal.
Why is oldest age rising when the queue is small?
Inspect the oldest eligible items and their permitted workers. An item may be routed to a pool without available capacity, may be in a retry loop, or may need a different dependency than the rest of the queue. Confirm that the age represents eligibility and the customer deadline you intend to protect. Use the finding to decide whether to add capacity or resolve the blocked work.
Why is the actual recommendation different from total backlog divided by target?
The simple arithmetic describes a fixture under defined assumptions. The controller applies configuration such as minimum and maximum replicas, tolerance, stabilization and policies. Timing and metric freshness also matter. First compare the adapter value, selector and current replica observation on a known input. Then read which policy explains the remaining difference.
Does no metric mean I should scale to the minimum?
An unavailable sample provides no observation of current ready work. Compare with the authoritative queue and inspect controller status. Your deployment may intentionally allow a documented fallback or keep a minimum of warm workers. Verify that outcome on the actual policy, including any other metrics, before treating it as a safe response.
Can a queue autoscaler use both CPU and backlog?
Kubernetes HPA supports multiple metrics. Compare the recommendation from each in a controlled fixture and observe how the deployed policy handles loss of either metric. Confirm that the signals describe the intended worker pool. Pair the policy with a measured outcome in successful completions and waiting time, so a valid controller result is judged against the problem it is supposed to solve.
sinc-LLM