工作线程和工作流的节奏配置

Cadence configuration for worker threads and workflow

工人和工作流之间的比例是多少以及如何管理 线程,以便工作人员和工作流程数量之间不应该中断 如果我启动更多数量的工作流程,则会抛出以下错误

没有足够的线程来执行工作流。如果此消息持续出现,则应减少 WorkerOptions.maxConcurrentWorklfowExecutionSize 或 WorkerOptions.maxWorkflowThreads增加了。

处于阻塞状态的工作流在内存中保持活动状态?? 处于等待状态的工作流不断检查条件? 在下面的示例中,线程正在等待信号, 工作流的数量被缩放到 million/day 并且 timetocloseWorkflow = 2 天。 触发信号的平均时间是相应工作流程启动后的 1 天

public class TestWorkflowImpl implements TestWorkflow {

 private static final Logger logger = LoggerFactory.getLogger(TestWorkflow.class);
 private int counter = 0;

 private final CounterPrintActivity cpa = Workflow.newActivityStub(CounterPrintActivity.class);

 @Override
 @WorkflowMethod
 public String startWorkflow() {
 Workflow.await(() ->counter >= 1000);
 return "Complete";
 }

 @Override
 public int getCurrentStatus() {
 return counter;
 }

 @Override
 public void setCount(int setNum) {
 logger.info("In signal");
 counter = counter+setNum;
 }

--

What will be the ratio between worker and workflow and how to manage the threads so that there should not be outage between workers and number of workflows If I start more number of workflow following error is thrown

没有这样的比率,因为阻塞的工作流根本不消耗工作内存(在它们被推出缓存之后)。因此,如果这些工作流没有取得任何进展,可能会有数十亿个受阻的工作流和一个工作人员。

Not enough threads to execute workflows. If this message appears consistently either WorkerOptions.maxConcurrentWorklfowExecutionSize should be decreased or WorkerOptions.maxWorkflowThreads increased.

maxWorkflowThreads 定义所有当前正在执行和缓存的工作流可以使用的线程数。

maxConcurrentWorklfowExecutionSize 定义可以并行执行多少个工作流任务。

“没有足够的线程来执行工作流”异常表示没有足够的线程来执行当前 运行 工作流任务。例如,如果每个工作流使用两个线程并且 maxConcurrentWorklfowExecutionSize 是 100,那么 maxWorkflowThreads 应该至少是 200。使用这样的设置 0 工作流将被缓存,因为所有线程将被当前正在执行的工作流任务消耗.所以一般来说,保持 maxWorkflowThreadsmaxConcurrentWorklfowExecutionSize 高得多以支持缓存更好。

the workflow in blocking state remains active in memory ??

它会保持缓存状态,直到另一个工作流需要取得进展并将缓存的工作流踢出。之后,当它收到一些新事件(如计时器、信号或 activity 完成。

时,阻塞的工作流将加载到工作内存中

Workflow in await state continuously checks for condition ?? More the number of workflow in await state will keep worker occupied ??

它仅在处理某些新事件时检查。当什么都没有发生时,检查不会被执行。

In below example the thread is waiting for a signal, the number of workflows is scaled to a million/day and timetocloseWorkflow = 2days. And the average time to trigger a signal is 1 day after the respective workflow is started

假定工作人员可以跟上工作流任务处理速度,此方案应该可以正常工作。