Skip to content

Commit 2806add

Browse files
committed
add comments
1 parent 5214d75 commit 2806add

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/main/java/com/uber/cadence/samples/hello/HelloWorkerSetup.java

+18
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,24 @@ public String composeGreeting(String greeting, String name) {
7474

7575
public static void main(String[] args) {
7676
// Start a worker that hosts both workflow and activity implementations.
77+
78+
/**
79+
* If you see error "Not enough threads to execute workflows" exception it indicates that there are
80+
* not enough threads to execute currently running workflow tasks.
81+
*
82+
* For example, if each workflow uses two threads(using Asycn function) and maxConcurrentWorklfowExecutionSize is 100,
83+
* and assuming the factory only creates one worker. Then maxWorkflowThreads should be at least 200.
84+
* With such setup 0 workflows will be cached as all the threads would be consumed by the currently executing workflow tasks.
85+
* So in general it is better to keep maxWorkflowThreads much higher than maxConcurrentWorklfowExecutionSize to support caching.
86+
*
87+
* maxWorkflowThreads defines how many threads all currently executing and cached workflows can use.
88+
* It's a Factory level option, meaning that the thread pool is shared across all workers created by the factory.
89+
*
90+
* maxConcurrentWorklfowExecutionSize defines how many workflow tasks can execute in parallel.
91+
* It's a worker level option.
92+
*
93+
*
94+
*/
7795
Worker.Factory factory = new Worker.Factory(DOMAIN,
7896
new Worker.FactoryOptions.Builder()
7997
.setMaxWorkflowThreadCount(1000)

0 commit comments

Comments
 (0)