Question/Request: Behavior of GRAPH_ENGINE_SCALE_UP_THRESHOLD for parallel execution #21671

Closed
opened 2026-02-21 20:13:47 -05:00 by yindo · 1 comment
Owner

Originally created by @NH1199 on GitHub (Jan 15, 2026).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

Hello Dify team,
Thank you for the great work on Dify. I have a question and a feature request regarding parallel execution in the graph engine.

What I’m trying to do

I would like to connect multiple LLM nodes in parallel and have them execute concurrently. With the default settings, they did not seem to run at the same time, so I looked for configuration options and found these environment variables:

  • GRAPH_ENGINE_MIN_WORKERS
  • GRAPH_ENGINE_MAX_WORKERS
  • GRAPH_ENGINE_SCALE_UP_THRESHOLD

https://github.com/langgenius/dify/blob/4a197b94585a25c0f79bce4227b7ef3f89680ad0/api/.env.example#L521

Observed behavior

Based on the description of GRAPH_ENGINE_SCALE_UP_THRESHOLD (“Queue depth threshold that triggers worker scale up (default: 3)”), I assumed that lowering this value would allow workers to scale up earlier and therefore improve parallel execution.

Because the value is constrained as PositiveInt, I set it to 1. However, the behavior did not match my expectation.

From the implementation, it seems that when GRAPH_ENGINE_MIN_WORKERS=1 and GRAPH_ENGINE_SCALE_UP_THRESHOLD=1, executing n parallel nodes results in only (n - 1) workers being started, meaning one node always remains waiting.
https://github.com/langgenius/dify/blob/0e33dfb5c20c450b6e54ca186995d414bd613d1d/api/core/workflow/graph_engine/worker_management/worker_pool.py#L176

I also found an issue where increasing GRAPH_ENGINE_MIN_WORKERS is used as a workaround: https://github.com/langgenius/dify/issues/26565

Request / questions

Would it be possible to allow GRAPH_ENGINE_SCALE_UP_THRESHOLD to be set to 0 (or otherwise adjust the scale-up condition, e.g. if queue_depth > self._scale_up_threshold and current_count < self._max_workers) so that workers can scale up immediately for parallel nodes?

Also, I’m not fully sure why GRAPH_ENGINE_SCALE_UP_THRESHOLD exists in the first place (and why the default is 3). When nodes are explicitly connected in parallel, is it intended/default behavior that the same number of workers will not start, causing one node to wait?

Any clarification or guidance would be greatly appreciated. Thank you for your time and consideration.

2. Additional context or comments

No response

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
Originally created by @NH1199 on GitHub (Jan 15, 2026). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] Please do not modify this template :) and fill in all the required fields. ### 1. Is this request related to a challenge you're experiencing? Tell me about your story. Hello Dify team, Thank you for the great work on Dify. I have a question and a feature request regarding parallel execution in the graph engine. ### What I’m trying to do I would like to connect multiple LLM nodes in parallel and have them execute concurrently. With the default settings, they did not seem to run at the same time, so I looked for configuration options and found these environment variables: - `GRAPH_ENGINE_MIN_WORKERS` - `GRAPH_ENGINE_MAX_WORKERS` - `GRAPH_ENGINE_SCALE_UP_THRESHOLD` https://github.com/langgenius/dify/blob/4a197b94585a25c0f79bce4227b7ef3f89680ad0/api/.env.example#L521 ### Observed behavior Based on the description of `GRAPH_ENGINE_SCALE_UP_THRESHOLD` (“Queue depth threshold that triggers worker scale up (default: 3)”), I assumed that lowering this value would allow workers to scale up earlier and therefore improve parallel execution. Because the value is constrained as `PositiveInt`, I set it to `1`. However, the behavior did not match my expectation. From the implementation, it seems that when `GRAPH_ENGINE_MIN_WORKERS=1` and `GRAPH_ENGINE_SCALE_UP_THRESHOLD=1`, executing *n* parallel nodes results in only *(n - 1)* workers being started, meaning one node always remains waiting. https://github.com/langgenius/dify/blob/0e33dfb5c20c450b6e54ca186995d414bd613d1d/api/core/workflow/graph_engine/worker_management/worker_pool.py#L176 I also found an issue where increasing `GRAPH_ENGINE_MIN_WORKERS` is used as a workaround: https://github.com/langgenius/dify/issues/26565 ### Request / questions Would it be possible to allow `GRAPH_ENGINE_SCALE_UP_THRESHOLD` to be set to `0` (or otherwise adjust the scale-up condition, e.g. `if queue_depth > self._scale_up_threshold and current_count < self._max_workers`) so that workers can scale up immediately for parallel nodes? Also, I’m not fully sure why `GRAPH_ENGINE_SCALE_UP_THRESHOLD` exists in the first place (and why the default is `3`). When nodes are explicitly connected in parallel, is it intended/default behavior that the same number of workers will not start, causing one node to wait? Any clarification or guidance would be greatly appreciated. Thank you for your time and consideration. ### 2. Additional context or comments _No response_ ### 3. Can you help us with this feature? - [ ] I am interested in contributing to this feature.
yindo added the 💪 enhancement🙋‍♂️ question labels 2026-02-21 20:13:47 -05:00
yindo closed this issue 2026-02-21 20:13:47 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jan 15, 2026):

The GRAPH_ENGINE_SCALE_UP_THRESHOLD variable controls when the worker pool in Dify's graph engine adds more workers: it only scales up if the queue depth exceeds this threshold and the current worker count is below the max. The default value is 3, which acts as a modest guard to avoid aggressive scaling for small or transient queue spikes—it’s not optimized for immediate parallelism, but rather to prevent unnecessary worker churn in typical workloads. There’s no explicit rationale in the code for choosing 3, but it’s a common heuristic to avoid over-provisioning for minor bursts source.

If you set the threshold to 0, the pool will try to scale up whenever the queue is non-empty (queue_depth > 0), which can lead to aggressive worker spawning up to the max_workers cap. There are no explicit safeguards or warnings in the code about this, but the only protection is the max_workers limit and the slower scale-down logic for idle workers source.

For true parallelism (e.g., all parallel LLM nodes run at once), you can either set GRAPH_ENGINE_MIN_WORKERS to match the number of parallel nodes, or lower the threshold (with caution about resource usage). The current logic does not guarantee that all parallel nodes will start simultaneously unless enough workers are available or the threshold is low enough.

References:

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Jan 15, 2026): <!-- Answer --> The GRAPH_ENGINE_SCALE_UP_THRESHOLD variable controls when the worker pool in Dify's graph engine adds more workers: it only scales up if the queue depth exceeds this threshold and the current worker count is below the max. The default value is 3, which acts as a modest guard to avoid aggressive scaling for small or transient queue spikes—it’s not optimized for immediate parallelism, but rather to prevent unnecessary worker churn in typical workloads. There’s no explicit rationale in the code for choosing 3, but it’s a common heuristic to avoid over-provisioning for minor bursts [source](https://github.com/langgenius/dify/blob/2b021e8752a9b8e18867634f04144859b2f6c8f4/api/.env.example#L521-L527). If you set the threshold to 0, the pool will try to scale up whenever the queue is non-empty (queue_depth > 0), which can lead to aggressive worker spawning up to the max_workers cap. There are no explicit safeguards or warnings in the code about this, but the only protection is the max_workers limit and the slower scale-down logic for idle workers [source](https://github.com/langgenius/dify/blob/2b021e8752a9b8e18867634f04144859b2f6c8f4/api/core/workflow/graph_engine/worker_management/worker_pool.py#L75-L260). For true parallelism (e.g., all parallel LLM nodes run at once), you can either set GRAPH_ENGINE_MIN_WORKERS to match the number of parallel nodes, or lower the threshold (with caution about resource usage). The current logic does not guarantee that all parallel nodes will start simultaneously unless enough workers are available or the threshold is low enough. References: - [worker_pool.py scaling logic](https://github.com/langgenius/dify/blob/2b021e8752a9b8e18867634f04144859b2f6c8f4/api/core/workflow/graph_engine/worker_management/worker_pool.py#L75-L260) - [.env.example defaults and comments](https://github.com/langgenius/dify/blob/2b021e8752a9b8e18867634f04144859b2f6c8f4/api/.env.example#L521-L527) <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/0678c311-79eb-4c2f-8429-42b4b5348c3e?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/0678c311-79eb-4c2f-8429-42b4b5348c3e?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/0678c311-79eb-4c2f-8429-42b4b5348c3e?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/0678c311-79eb-4c2f-8429-42b4b5348c3e?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/0678c311-79eb-4c2f-8429-42b4b5348c3e?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/0678c311-79eb-4c2f-8429-42b4b5348c3e?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/0678c311-79eb-4c2f-8429-42b4b5348c3e?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20GRAPH_ENGINE_SCALE_UP_THRESHOLD%20variable%20controls%20when%20the%20worker%20pool%20in%20Dify%27s%20graph%20engine%20adds%20more%20workers%3A%20it%20only%20scales%20up%20if%20the%20queue%20depth%20exceeds%20this%20threshold%20and%20the%20current%20worker%20count%20is%20below%20the%20max.%20The%20default%20value%20is%203%2C%20which%20acts%20as%20a%20modest%20guard%20to%20avoid%20aggressive%20scaling%20for%20small%20or%20transient%20queue%20spikes%E2%80%94it%E2%80%99s%20not%20optimized%20for%20immediate%20parallelism%2C%20but%20rather%20to%20prevent%20unnecessary%20worker%20churn%20in%20typical%20workloads.%20There%E2%80%99s%20no%20explicit%20rationale%20in%20the%20code%20for%20choosing%203%2C%20but%20it%E2%80%99s%20a%20common%20heuristic%20to%20avoid%20over-provisioning%20for%20minor%20bursts%20%5Bsource%5D%28https%3A//github.com/langgenius/dify/blob/2b021e8752a9b8e18867634f04144859b2f6c8f4/api/.env.example%23L521-L527%29.%0A%0AIf%20you%20set%20the%20threshold%20to%200%2C%20the%20pool%20will%20try%20to%20scale%20up%20whenever%20the%20queue%20is%20non-empty%20%28queue_depth%20%3E%200%29%2C%20which%20can%20lead%20to%20aggressive%20worker%20spawning%20up%20to%20the%20max_workers%20cap.%20There%20are%20no%20explicit%20safeguards%20or%20warnings%20in%20the%20code%20about%20this%2C%20but%20the%20only%20protection%20is%20the%20max_workers%20limit%20and%20the%20slower%20scale-down%20logic%20for%20idle%20workers%20%5Bsource%5D%28https%3A//github.com/langgenius/dify/blob/2b021e8752a9b8e18867634f04144859b2f6c8f4/api/core/workflow/graph_engine/worker_management/worker_pool.py%23L75-L260%29.%0A%0AFor%20true%20parallelism%20%28e.g.%2C%20all%20parallel%20LLM%20nodes%20run%20at%20once%29%2C%20you%20can%20either%20set%20GRAPH_ENGINE_MIN_WORKERS%20to%20match%20the%20number%20of%20parallel%20nodes%2C%20or%20lower%20the%20threshold%20%28with%20caution%20about%20resource%20usage%29.%20The%20current%20logic%20does%20not%20guarantee%20that%20all%20parallel%20nodes%20will%20start%20simultaneously%20unless%20enough%20workers%20are%20available%20or%20the%20threshold%20is%20low%20enough.%0A%0AReferences%3A%20%20%0A-%20%5Bworker_pool.py%20scaling%20logic%5D%28https%3A//github.com/langgenius/dify/blob/2b021e8752a9b8e18867634f04144859b2f6c8f4/api/core/workflow/graph_engine/worker_management/worker_pool.py%23L75-L260%29%20%20%0A-%20%5B.env.example%20defaults%20and%20comments%5D%28https%3A//github.com/langgenius/dify/blob/2b021e8752a9b8e18867634f04144859b2f6c8f4/api/.env.example%23L521-L527%29)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31054)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#21671