Diagnosing Overload

A server answering 529 Site is overloaded, or holding PHP requests that never complete, is in one of two states, and they need opposite fixes:

  • Overloaded. The pool works, but it is offered more than it can serve.
  • Wedged. The pool has stopped taking work off its queue while all its threads are alive.

This page shows how to tell them apart from the connection metrics and the server log, how the wait budget behind QUEUE_WAIT_TIMEOUT_MS moves, and when to change it. The metrics need the internal server (INTERNAL_ADDR); the log lines do not.

What you see and what to do

What you see What it means What to do
529s, oxphp_admission_refused_total{reason="wait_timeout"} climbing, workers busy Overload: requests waited out their budget Add capacity: more PHP_WORKERS if the machine has cores to spare, or more replicas. Check oxphp_admission_wait_wasted_total first
oxphp_admission_wait_wasted_total climbing The pool started nothing during those waits, so waiting buys nothing Shorten QUEUE_WAIT_TIMEOUT_MS, and look for self-calls or handlers slower than the budget
529s with reason="waiting_full" or reason="waiting_bytes" The waiting set is full, by count or by body bytes Raise QUEUE_MAX_WAITING or QUEUE_MAX_WAITING_BYTES, or add capacity. See Sizing the waiting set
529s with reason="queue_full" The queue is full and waiting is off (QUEUE_WAIT_TIMEOUT_MS=0) Expected in fail-fast mode; read QUEUE_WAIT_TIMEOUT_MS=0 is not a shorter wait
oxphp_admission_wait_budget_us below its ceiling The pool is offered more than it can serve, by clients that leave before they are served Nothing for the budget itself: the server is protecting itself. Add capacity if it lasts
Queue depth not falling, oxphp_busy_workers at 0 A wedged pool See Reading queue depth against admission slots. A wedge does not usually clear on its own, so restart the instance
Readiness 503, oxphp_pool_stalled at 1 A wedge that has held for a minute (worker mode only) The orchestrator takes the instance out of rotation. See The wedged-pool signal
Many 499s, oxphp_request_cancelled_total{reason="client_abort"} climbing Clients leave before a worker reaches their request Keep QUEUE_WAIT_TIMEOUT_MS below the timeout of the load balancer in front
No response at all, oxphp_accept_stalled at 1 The MAX_CONNECTIONS budget is used up See Keeping headroom for the accept loop

What each refusal reason points at is listed under Refusal reasons.

Reading queue depth against admission slots

oxphp_queue_depth says what is waiting; oxphp_admission_slots_available says whether anything more can be let in. Read both against oxphp_busy_workers: the question is whether anything is moving, not how deep the queue is.

Slots available Queue depth Reading
> 0 0 Nothing waiting; normal
> 0 > 0 and falling between scrapes Ordinary backlog: the pool is behind but working through it
> 0 > 0 and not falling, with oxphp_busy_workers at 0 A wedge in its first phase: the pool has stopped taking work while admission still has room. Each arrival is answered 529 when its budget runs out, or 499 if its client left first
0 at oxphp_queue_capacity The same wedge once the queue has filled, or an overload the pool is far behind on. oxphp_busy_workers at 0 across several scrapes means the wedge; one sample can read that way under overload too
0 at or near 0 Permits held outside the queue. In one scrape that can be requests between admission and dispatch. Sustained across scrapes, it is permits taken and never given back: nothing can be admitted, and the server refuses every PHP request until it is restarted

The last three rows are what a stalled pool looks like. Everything else reads healthy: no worker is busy, liveness answers 200 throughout and readiness for the first minute, and static files are served normally. The refusal counters move, but they move under ordinary overload too. In a wedge, oxphp_admission_wait_wasted_total climbs with every 529 while the budget is at its ceiling, since no request starts while any of them waits.

oxphp_pending_requests rises with the stuck queue and then falls back as each arrival is answered on its own budget, so on its own it says nothing here. Against oxphp_queue_depth it does: a refused request leaves the pending count but stays in the queue until a worker picks it up. Pending near zero while depth sits at capacity is a wedge holding everything it was ever given.

Behind an impatient load balancer

A wedge is exactly what makes clients leave. Behind a load balancer whose timeout is shorter than QUEUE_WAIT_TIMEOUT_MS, arrivals become 499s that move neither refusal series, so oxphp_admission_wait_wasted_total can stay quiet through the whole incident. They land in oxphp_request_cancelled_total{reason="client_abort"}, and oxphp_queue_depth holds either way.

With QUEUE_WAIT_TIMEOUT_MS=0, a wedge is worse: a request that found a free queue slot has no deadline and is never answered (see below).

The stalled-pool warning

The server notices a wedge too. When two consecutive one-second scans see work waiting (requests in the queue, or refusals climbing) while at least one worker is idle and the pool has finished nothing, it logs:

json
{"timestamp":"2026-08-28T10:56:59.015691Z","level":"WARN","fields":{"message":"PHP requests are waiting while the pool has idle workers and got nothing done since the last scan","queue_depth":22,"queue_capacity":512,"admission_slots_available":490,"workers_idle":4}}

The line repeats about once a minute while the state lasts, and INFO PHP pool is reaching workers again follows once work moves. Like every JSON log line, it nests its values under fields, so an alert rule reads .fields.queue_depth, not .queue_depth.

The warning counts what the workers finished, not what clients received, so a storm of client aborts does not trigger it. Nothing is reported before the pool has finished its first request, so the first application bootstrap is not taken for a wedge.

A worker recycled later (on the memory ceiling or Worker::scheduleExit()) boots the application again and reads as idle until it takes a request. On a one-worker pool, or one whose other workers are all busy, a slow bootstrap can therefore log one warning followed by its recovery line within seconds. oxphp_workers_spawned_total moving at the same moment identifies it.

The warning is logged in worker mode only. Outside it, a worker blocks on the queue itself, so this kind of wedge does not arise. The three gauges are exported in every mode.

What the log says while requests are being shed

The server reports each overload episode, not each refused request. It watches the four overload reasons of oxphp_admission_refused_total on the same one-second scan, and the first scan that sees any of them move logs:

json
{"timestamp":"2026-09-16T11:02:41.337104Z","level":"WARN","fields":{"message":"PHP admission has started shedding requests under overload","refused":4812,"refused_queue_full":0,"refused_wait_timeout":4812,"refused_waiting_full":0,"refused_waiting_bytes":0,"queue_depth":896,"queue_capacity":896,"admission_slots_available":0,"wait_budget_us":15625,"wait_budget_ceiling_us":1000000}}
  • refused is what that one scan turned away. The exception is the first scan that has a queue to look at: it reports everything shed before it, such as arrivals that piled up while the pool was still loading the application.
  • refused_queue_full, refused_wait_timeout, refused_waiting_full and refused_waiting_bytes split refused by reason and add up to it. The reason decides which setting to change. All four are written even at zero, so a 0 rules a reason out.
  • queue_depth, queue_capacity and admission_slots_available are a snapshot taken at the scan, while refused covers the second just passed. A large refused next to an empty queue is a short burst that has already drained.
  • wait_budget_us well under wait_budget_ceiling_us means the server has already shortened the wait. Both are there because a budget driven to its floor and one configured that low look the same on their own.

On an instance without INTERNAL_ADDR, these fields (and the oxphp.shed_reason span attribute, where tracing is on) are the only place to read the reason.

While the episode lasts, the warning repeats as PHP admission is still shedding requests under overload. It comes at most once a minute and only on a scan that is itself refusing, so the gap can reach almost two minutes. The repeat adds episode_refused, the running total, and its episode_refused_* fields split that total, not the scan's. The production configurations log at warn, so there the repeat is the only line that says what the episode has been made of. An episode that ends inside its first minute has no repeat.

A minute with no refusal ends the episode, at INFO:

json
{"timestamp":"2026-09-16T11:05:52.812440Z","level":"INFO","fields":{"message":"PHP admission has stopped shedding requests","episode_refused":18374,"episode_refused_queue_full":0,"episode_refused_wait_timeout":17950,"episode_refused_waiting_full":424,"episode_refused_waiting_bytes":0,"duration_ms":131000,"queue_depth":0,"admission_slots_available":896}}

duration_ms runs to the last refusal, not to the line, so the quiet minute that ends the episode is not counted. Gaps shorter than a minute are folded into one episode, which keeps the output to two lines a minute at most.

The report is logged in every routing mode. It ignores shutting_down and pool_unavailable, so a restart or a vanished pool does not read as load.

Shedding never changes what /health/readiness answers, and no gauge reports it. An instance shedding 529s answers quickly on a working pool, and pulling overloaded replicas out of rotation one after another would leave the Service with no endpoints. Answer overload with capacity. A wedged pool sheds too, and in worker mode it does answer 503 once it has held for a minute. The queue tells them apart: a pool that is only behind drains it, a wedged one does not.

The wait budget

QUEUE_WAIT_TIMEOUT_MS (default 1000) is the longest a request may wait for a PHP worker before it is refused with 529. It is a ceiling, not a fixed value. It sets one deadline, stamped on arrival, that covers both waits: for a slot in the queue, and inside the queue for a worker. oxphp_admission_wait_budget_us publishes the budget in force, and oxphp_admission_wait_budget_ceiling_us the configured ceiling.

How the wait budget comes down and goes back up

While the work the waiting admits is completing for clients who have already left, the server shortens the budget on its own, and steeply:

  • Down. The budget is halved each time a quarter or more of what the pool started went to clients who had already gone. This is measured over a window of at least eight started requests, not a fixed interval.
  • Floor. A sixty-fourth of the ceiling (15.6 ms at the default) or 10 ms, whichever is larger, and never above the ceiling itself.
  • Up. It walks back in eighths of the ceiling, only while the queue is observed empty and less than a quarter of what the pool started went to departed clients. The ordinary trickle of closed tabs does not hold it down, and a server whose queue never empties keeps the shortened budget until the load lets up.

With QUEUE_WAIT_TIMEOUT_MS=1000, expect about 15.6 ms during an episode. Write alerts on the ratio of oxphp_admission_wait_budget_us to oxphp_admission_wait_budget_ceiling_us, not on the configured number.

A budget below its ceiling means the pool is offered more than it can serve, by clients less patient than the ceiling. The shorter budget stops it from handing workers requests nobody is waiting for. Sitting at the floor through an episode is normal. Sitting there with oxphp_queue_depth at zero is not: a quarter or more of what the pool still finishes on an empty queue is for departed clients.

The shortening is driven by clients that close their connection. Clients that stop waiting without closing produce no signal, and the ceiling stays in force.

The deadline is enforced from both ends

When the deadline passes, the request is answered 529, and a worker that reaches a request past its deadline refuses it instead of running it. So a queued request nobody picks up does not wait forever. The budget bounds only the wait: a handler that a worker started inside the budget runs as long as it runs.

Clients that leave while they wait

A client that closes its connection while waiting for a queue slot gives its place back at once, on HTTP/1.1 and HTTP/2. One that closes while already in the queue keeps its place until a worker reaches it or the budget runs out. It is then answered 499 and counted in oxphp_request_cancelled_total{reason="client_abort"}, not as an overload refusal.

A client that stops waiting without closing holds its place until it is admitted or the budget runs out, and if a worker frees up first, its script runs for nobody. Keep the budget below the timeout of anything in front of the server.

Reading the wasted-wait and abandoned-work counters

Reading oxphp_admission_wait_wasted_total

This counter counts requests that waited out their whole budget while the pool started no request at all. It is a subset of oxphp_admission_refused_total{reason="wait_timeout"}. It counts work started, not entries leaving the queue, because a worker clearing requests their deadlines already answered moves the queue without serving anybody.

It counts only while oxphp_admission_wait_budget_us is at its ceiling. Once the budget is shortened, "the pool started nothing" says more about the short window than about the pool: four workers on quarter-second handlers start one request every 62 ms, so at the floor most waits end between two starts. A pool that starts nothing never gives the server enough started requests to shorten the budget, so it keeps its ceiling and this counter stays armed.

Sustained non-zero means waiting buys nothing: shorten QUEUE_WAIT_TIMEOUT_MS, so those requests are refused sooner instead of holding a connection for most of the budget.

The classic cause is an application calling back into this same server over HTTP (see When the application calls itself). The counter is not a self-call detector, though: a pool whose handlers all run longer than the budget frees nothing during a wait either. In worker mode, oxphp_worker_request_duration_us (handler time, without the queue wait) tells them apart: handlers below the budget while this counter climbs means the waits are not just queued behind slow work. Do not use oxphp_request_duration_us for this, since it includes these refusals, each adding nearly a whole budget. Outside worker mode, use the application's own timings.

Reading oxphp_abandoned_work_total

This counts requests a worker took off the queue whose client had already gone, and it is what the server adjusts the wait budget against. Read the two together:

  • the counter climbing while the budget falls is the server doing its job;
  • the counter climbing with the budget still at its ceiling means clients leave during their handler, not during their wait, so the wait is not what to shorten.

It counts requests, not wasted CPU. A request whose client left while it was queued is answered at pickup before any PHP runs, while one whose client left mid-handler has cost a whole handler. A request whose response went out before its handler finished (a stream whose headers were sent, or an early answer from oxphp_finish_request()) is not counted, so the end of every SSE session is left out. Only a client that closes its connection is visible here.

When to lower QUEUE_WAIT_TIMEOUT_MS

Lower it in two cases:

  • A load balancer in front has a shorter timeout of its own. Once it has given up, nobody is waiting for the answer, so a longer wait here serves nobody.
  • The application calls back into this same server over HTTP. The inner call needs a worker that the outer one holds while it waits, so the wait is spent for nothing however long it is.

When the application calls itself

oxphp_admission_wait_wasted_total counts the waits a self-call spends for nothing, but only while the budget is at its ceiling. Whether the budget comes down depends on who calls the self-calling application, not on the self-call:

  • Patient callers, such as an internal cron or a sidecar on a long timeout: nothing is abandoned, the ceiling stands, and this counter names the pattern.
  • Impatient callers: the pool starts a request every time an outer one gives up on its inner call, which gives the server the evidence to shorten the budget (two halvings within seconds of the load starting, in a measured run). The counter then goes quiet after the arrivals from before the drop, so a 0 does not rule the pattern out.

Once the budget has come down, nothing in /metrics names a self-call. An ordinary overload of impatient clients reads the same: budget low, oxphp_abandoned_work_total climbing, wasted waits near zero. The wedge rows of the queue-depth table do not apply either, because a self-caller's workers are busy inside the handler that is waiting. Look for the pattern in the application's own outbound calls, such as an HTTP client pointed at the application's own host name.

Those wedge rows do catch one case the counter misses: a pool that stops taking work while an overload already had the budget down, where oxphp_queue_depth does not fall and no worker is busy.

QUEUE_WAIT_TIMEOUT_MS=0 is not a shorter wait

0 turns off the wait for a queue slot: a request that finds the queue full is refused at once, with reason="queue_full". It leaves the wait inside the queue unbounded, so a request that finds a free slot is queued with no deadline. On a pool that picks nothing up, such as a wedge or a self-call, that request is never answered. Pair 0 with a QUEUE_CAPACITY small enough that the queue is full by the time it matters.

Prompts for your agent

These prompts assume an agent with the OxPHP documentation MCP server connected. The agent reads the pages it needs itself.

prompt
My OxPHP server is answering 529s. Read the `operations/overload` and `operations/configuration` pages through the OxPHP documentation MCP server. Check the queue and worker settings in this repository against the timeouts of the load balancer or proxy in front of OxPHP, look for code that calls this same application back over HTTP, and tell me which setting to change and why.
prompt
Write Prometheus alert rules that tell overload apart from a stalled OxPHP worker pool. Read the `operations/overload` and `operations/metrics` pages through the OxPHP documentation MCP server. Put them where this repository keeps its alerting rules, and say in a comment on each rule what it means when it fires and which setting to change.

See also

Found a mistake? Report it