Does one ComfyUI process run prompts in parallel? How are queue order, priority and websocket targeting (client_id) decided?
Problem. Capacity planning and result routing for scripts or services in front of ComfyUI. Conditions. ComfyUI v0.42.5, single server process. Method. main.py starts exactly one daemon thread running prompt_worker, which pulls from PromptQueue, calls e.execute(...) synchronously, then task_done. PromptQueue.put uses heapq.heappush on tuples whose first element is 'number', so lower number runs first; 'front': true negates the auto counter. Inference: because the counter grows with every submission, a later front submission gets a more negative number and so runs before earlier front items (LIFO among front items). Parallel throughput needs more processes (instances, GPUs) with your own scheduler. execute_async stores extra_data['client_id'] in a single server-wide field; add_message sends execution_start/cached/success only if a client_id exists (broadcast False), addressing that sid, so a prompt submitted without client_id gets no per-prompt websocket events; the same events are ke...
Structured fields
{
"citations": [
{
"url": "https://raw.githubusercontent.com/comfyanonymous/ComfyUI/483dae4326356b81de05d27aca3f433dd323cc25/main.py",
"note": "main(): thread start; post_prompt priority; ExecutionStatus/history; PromptExecutor.add_message"
},
{
"url": "https://raw.githubusercontent.com/comfyanonymous/ComfyUI/483dae4326356b81de05d27aca3f433dd323cc25/server.py",
"note": "main(): thread start; post_prompt priority; ExecutionStatus/history; PromptExecutor.add_message"
},
{
"url": "https://raw.githubusercontent.com/comfyanonymous/ComfyUI/483dae4326356b81de05d27aca3f433dd323cc25/execution.py",
"note": "main(): thread start; post_prompt priority; ExecutionStatus/history; PromptExecutor.add_message"
}
]
}Evidence claims
- [sourced_fact] Problem. Capacity planning and result routing for scripts or services in front of ComfyUI. Conditions. ComfyUI v0.42.5, single server process. Method. main.py starts exactly one daemon thread running prompt_worker, which pulls from PromptQueue, calls e.execute(...) synchronously, then task_done. PromptQueue.put uses heapq.heappush on tuples whose first element is 'number', so lower number runs first; 'front': true negates the auto counter. Inference: because the counter grows with every submission, a later front submission gets a more negative number and so runs before earlier front items (LIFO among front items). Parallel throughput needs more processes (instances, GPUs) with your own scheduler. execute_async stores extra_data['client_id'] in a single server-wide field; add_message sends execution_start/cached/success only if a client_id exists (broadcast False), addressing that sid, so a prompt submitted without client_id gets no per-prompt websocket events; the same events are kept in the history entry's status.messages. History is bounded by MAXIMUM_HISTORY_SIZE = 10000 entries. Failure modes. Assuming multiple prompts run concurrently; connecting /ws without the clientId used at submit time and seeing nothing; relying on /history after 10,000 jobs. Limitations. The front-ordering detail is inferred from number = -number with an incrementing counter; not run. Version and date. v0.42.5. · locator: main(): thread start; post_prompt priority; ExecutionStatus/history; PromptExecutor.add_message source
Rights
| component | license | hosting | redistribution | modification | training | Evidence and notes |
|---|---|---|---|---|---|---|
| documentation | unknown | permitted | permitted | unknown | unknown | Applies to this original summary only, not to the cited sources. |
Linked records
- cites → https://raw.githubusercontent.com/comfyanonymous/ComfyUI/483dae4326356b81de05d27aca3f433dd323cc25/execution.py
- cites → https://raw.githubusercontent.com/comfyanonymous/ComfyUI/483dae4326356b81de05d27aca3f433dd323cc25/main.py
- cites → https://raw.githubusercontent.com/comfyanonymous/ComfyUI/483dae4326356b81de05d27aca3f433dd323cc25/server.py