Jenkins Queue Scheduling Latency under Concurrent Request Loads
0 reputation · 05 Jul 2021, 15:44 UTC
0 reputation · 05 Jul 2021, 15:44 UTC
Jenkins manages job scheduling through a centralized queue system. Documented behavior indicates that the queue is single-threaded, meaning items are dequeued and scheduled one at a time. This mechanism remains consistent across Jenkins 2.x releases.
When a high volume of builds is triggered simultaneously via the REST API or UI, the master thread handles both the request processing and the queue management. This creates a bottleneck where idle executors on multiple nodes may remain unused while the master sequentially processes the queue items.
While the Throttle Concurrent Builds plugin can limit executions per job or label, it operates on top of the existing queue rather than modifying the underlying scheduling architecture.
Jenkins maintains a single internal queue that is processed by the master’s Queue.maintain() loop. Items are dequeued and scheduled one at a time, regardless of how many executors are idle on agents. There is no documented configuration or plugin that enables parallel dequeuing of this queue.
When the rate of queued items exceeds the master’s ability to process the queue, the time each item spends waiting in the queue (queue latency) increases roughly linearly with the number of pending items. Executors may stay idle while the master is still working through the queue.
hudson.model.Queue via Manage Jenkins → System Log → Add Log Recorder.Queue.LeftItem appears in the log; the difference is the queue latency for that item./queue/api/json?tree=items[*][timestamp,inQueueSince,why,blocked,stuck] and compute now - inQueueSince for each item; plot latency versus queue length./computer/api/json. Compare observed latency increase with the predicted linear trend.Queue.Task implementations or plugins that extend Queue.maintain() and optimize or disable them if they add significant latency.The point at which queue latency dominates over executor availability depends on the master’s CPU capacity and the average time to process a queue item. For example, on a master handling roughly 200 queue‑maintenance operations per second (≈5 ms per item), latency becomes noticeable when more than ~10‑15 builds are queued per second. To give a precise threshold for your environment, we need the observed average time per queue maintenance operation on your master.
Please provide the measured average duration of a single Queue.maintain() iteration (or the observed queue processing rate) so we can calculate the specific concurrency threshold for your setup.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.