[FEATURE] Not working parallel Node in AgentFlow 2
Overview
When multiple LLM nodes are arranged in a parallel structure within the flowchart UI, the expected behavior is for them to execute concurrently. However, the current execution engine processes these nodes sequentially. This discrepancy between the visual representation in the UI and the actual system behavior can cause confusion for users and prevents the performance benefits of parallel processing.
Steps to Reproduce
In the flowchart editor, create a flow where two or more 'LLM' nodes (e.g., LLM 0, LLM 1) branch out in parallel from a single source node (e.g., 'Start'). Merge the outputs of these parallel LLM nodes into a single subsequent node (e.g., 'Agent 0'), as shown in the provided image. Execute the configured flow. Observe the execution logs or debug the start/end times for each node.
Expected Behavior
As implied by the UI flowchart, the LLM 0 and LLM 1 nodes should execute concurrently. The total execution time for this parallel section should be approximately the time taken by the longest-running of the two nodes.
Actual Behavior
The nodes are executed sequentially. For instance, LLM 0 runs and completes entirely before LLM 1 begins its execution. The total execution time is the sum of the execution times of both LLM nodes.
Root Cause Analysis (Optional)
This behavior appears to be caused by the main while loop in the executeAgentFlow function. It uses nodeExecutionQueue.shift() to process only one node at a time, and await executeNode() blocks further execution until the current node is finished. The logic lacks a mechanism (e.g., Promise.all) to handle concurrent node execution.
Suggestion
To ensure a consistent user experience and to improve performance, it is recommended to refactor the execution logic to support concurrent processing for nodes that are structured in parallel in the UI.
noticed this too! this is very much needed 👍
Even though parallel nodes are processed sequentially, however they do not overlap with each other
Start --|-- LLM 1 --|-- LLM 3
|-- LLM 2 --|
Both LLM1 and LLM2 are triggered by the Start node and inherit the same memory context, and LLM3 does not begin its execution until both LLM1 and LLM2 have finished.
It is not just a simple sequential loop; instead, it uses a queue-based algorithm to check for the predecessors of the nodes and only proceeds to the next once every item in the queue has finished executing. Refer more
Technically we can run these parallels path by spinning up multiple NodeJS threads with each processing one path, but I personally dont see the benefit of doing so due to the excessive CPU and RAM usage, yet still achieving the same outcome, unless Im missing something
@HenryHengZJ Thank you for the detailed explanation of your architecture. It makes sense to prioritize stability and predictable resource usage by processing nodes sequentially.
You mentioned avoiding multiple threads to save CPU and RAM, which is a valid concern. I have a question regarding this: are you equating parallel execution with creating new threads?
I was wondering about a non-threaded, concurrent approach for I/O-bound nodes like LLM calls. For instance, initiating calls to LLM1 and LLM2 at the same time and using something like Promise.all to wait for their completion before starting LLM3. This should improve speed without the thread overhead.
You ended with "unless I'm missing something," and I'm genuinely curious if there's a reason this concurrent model was also avoided (perhaps for rate-limiting or debugging simplicity?). I'd love to hear your thoughts.
@grapestore also, I have noriced that this current approach brings some unexpected misconfiguration, as I reported here https://github.com/FlowiseAI/Flowise/issues/4710
+1 having true parallel execution would open up quite a few ideas that require many (isolated) subtasks to be executed rapidly. By executing these steps in sequence the total execution time rapidly goes up...
Any updates on this?
Any updates on this?
Never will happen
Any updates on this?
Never will happen
That's too bad :( would massively speed up certain workflows. Didn't V1 have true parallel execution?
@alexsstockton @grapestore Although this is not parallel execution on engine level. I have created a flowise tool node to allow you to execute agentflows in parallel. Thus allowing you to create sub flows and execute them in parallel and use the combined responses in the main flow.
You can check it out here: https://github.com/TS-Eichhorn/ParallelSubflows-Custom-Flowise-Node
If you have any suggestions for improvement let me know
@alexsstockton @grapestore Although this is not parallel execution on engine level. I have created a flowise tool node to allow you to execute agentflows in parallel. Thus allowing you to create sub flows and execute them in parallel and use the combined responses in the main flow.
You can check it out here: https://github.com/TS-Eichhorn/ParallelSubflows-Custom-Flowise-Node
If you have any suggestions for improvement let me know
Thank you so much, I will check this out later today!
What we ended up doing was creating code in custom tools for all tasks that require parallel processing. It works, but kind of beats the idea of drag and drop node-based workflow editing if we need to manually write code to make API calls to the LLM.
@lampyon-canada check out the node i posted earlier in this thread. It still is a bit of 'workaround' but does allow you to drap and drop edit 'parallel' flows