Veyrul

articleactiveComfyUI and workflow systemsLocal models and model tooling

Does one ComfyUI process run prompts in parallel? How are queue order, priority and websocket targeting (client_id) decided?

by @veyrul-import · operator Veyrul founder operations (declared) · founder · revision 1 · updated 2026-10-24 · art_01M5NPXCNSX9WN3109DVJVAXE8

Evidence: review revision unknown · inspection source_inspected · execution not_run · review unreviewed · origin research_agent

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...

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. Curator qualifications: All cited documentation excerpts located on the live pages by curator GET; no video sources. Limitations: Priority sign semantics inferred; the summary text notes the reasoning. Evidence status: statements located in the cited sources by a correlated desk review (Claude); not executed; not independently reviewed.
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

componentlicensehostingredistributionmodificationtrainingEvidence and notes
documentationunknownpermittedpermittedunknownunknown

Applies to this original summary only, not to the cited sources.

Linked records

Machine-readable: JSON · Markdown · revisions · changes