How workers & queues work
The queue
Jobs submitted with /run or /runsync are stored in a durable, per-endpoint queue. Workers take jobs in first-in, first-out order. Jobs sent with policy.lowPriority: true are only picked up when no normal-priority job is waiting.
- A job waits in the queue for at most its time-to-live (
policy.ttlInSec, default 24 hours). If no worker picks it up in time it ends asTIMED_OUT. - The time a job spends waiting is reported as
delayTime(milliseconds) on the job object. It includes any cold start the job had to wait for. - Queue depth is visible on
GET /healthasjobs.inQueue. UsePOST /purge-queueto drop every queued job, for example after a bad deploy.
Autoscaling
The autoscaler re-evaluates each endpoint every second and keeps the number of workers between minWorkers and maxWorkers. How aggressively it scales up depends on scalerType:
| scalerType | scalerValue means | Scales up when |
|---|---|---|
QUEUE_DELAY | Seconds (default 4) | The oldest queued job has waited longer than scalerValue seconds. Good default: it ignores short bursts that existing workers absorb. |
REQUEST_COUNT | Target jobs per worker | In-queue plus in-progress jobs divided by scalerValue exceeds the current worker count. Use it for latency-sensitive endpoints with predictable job duration. |
Scaling down is controlled by idleTimeoutInSec: a worker that has had no job for that many seconds is stopped. Workers are never stopped in the middle of a job.
Worker lifecycle
Each worker has an ID like wrk_8q3m2x9k and moves through the states below. List them with GET /endpoints/{endpointId}/workers or on the endpoint's Workers tab in the console.
| Worker state | Meaning |
|---|---|
INITIALIZING | The worker is starting: pulling the image or restoring a Warmstart snapshot, then running your module-level code. |
IDLE | Ready and waiting for a job. Billed until the idle timeout expires (Flex) or always (Active). |
RUNNING | Executing one or more jobs. |
THROTTLED | Scheduled but waiting for a GPU from your priority list to free up on the host. |
UNHEALTHY | The worker crashed or failed its health check. It is replaced automatically. |
A worker's life starts with initialization: the image is pulled (or restored from a Warmstart snapshot), the container starts and your module-level code runs, typically loading model weights onto the GPU. Only then does the SDK start polling for jobs.
Cold starts and Warmstart
A cold start is everything that happens before a new worker can take its first job: image pull, container start and model load. For a 10 GB image with a 7 GB model this can take 30 to 90 seconds.
Warmstart removes most of that. After a worker finishes initializing, Apipods snapshots its memory and disk and caches the snapshot on hosts in the endpoint's regions. New workers restore from the snapshot instead of starting from scratch, typically in under 2 seconds. The first worker after each deploy is always a full cold start, because that is the worker that produces the snapshot.
apipods.serverless.start() is captured by the snapshot; work done inside the handler is repeated for every job.GPU selection
When a worker starts, the scheduler walks gpuPoolIds in order and takes the first pool with free capacity in one of the endpoint's regionIds. If none is free, the worker waits in THROTTLED until a GPU frees up. Listing two or three pools that all fit your model is the single best way to avoid throttling. The pool a worker landed on is available inside the container as APIPODS_GPU_POOL_ID.
Limits
| Limit | Value |
|---|---|
| Concurrent GPUs per organization (pods + workers) | Plan limit: 10 on Starter, 50 on Team, custom on Enterprise |
| maxWorkers default | 3 |
| Execution timeout | 600 s default, up to 86400 s (24 h) |
| Idle timeout | 5 s default, 1 to 3600 s |
| Job time-to-live in queue | 86400 s default |
| Input payload | 10 MB for /run, 20 MB for /runsync |