Instances hang with concurrency

cancel
Showing results for 
Search instead for 
Did you mean: 
malizor
Member II

Instances hang with concurrency

Jump to solution

Hi,

I attached a simple .BPMN with which I managed to reliably reproduce my issue.

It only contains script tasks, though I originally noticed this behavior with Java service tasks.

There are 5 script tasks witch are all marked as async.
The first 4 do nothing and the fifth one sleeps for 2 minutes (in my experience, it works the same with any other service task that is "long to process").

What I observe when launching new instances is the following:

  • The first and second instances go through the workflow and wait on the wait_script
  • The third one stay on script1 for some seconds then goes to wait_script
  • The fourth one stay on script1 until the first two instances finish.

I also tried launching 100 instances of this same workflow at once.
In this case I observed that they are all processed very slowly. It seems the instances advanced by batches of around 20, in no particular order, and that they stayed on wait_script for more than 2 minutes.
All in all, the 100 instances needed about 20 minutes to complete.

Note that I tried to modifie the asyncExecutor settings but I did not notice any change.

I set the following settings:

<property name="jobExecutorActivate" value="false" />
<property name="asyncExecutorEnabled" value="true" />
<property name="asyncExecutorActivate" value="true" />

and:

<bean id="asyncExecutor" class="org.activiti.engine.impl.asyncexecutor.DefaultAsyncJobExecutor">
    <property name="corePoolSize" value="100" />
    <property name="maxPoolSize" value="2000" />
    <property name="keepAliveTime" value="3000000" />
    <property name="queueSize" value="20000" />
    <property name="maxTimerJobsPerAcquisition" value="2000" />
    <property name="maxAsyncJobsDuePerAcquisition" value="2000" />
    <property name="defaultAsyncJobAcquireWaitTimeInMillis" value="10000" />
    <property name="defaultTimerJobAcquireWaitTimeInMillis" value="10000" />
    <property name="timerLockTimeInMillis" value="60000" />
    <property name="asyncJobLockTimeInMillis" value="60000" />
</bean> ‍‍‍‍‍‍‍‍‍‍‍‍                                                                                       

I don't understand why instances seems to get stuck when other are being processed.

Why all my instances do not go directly at the wait_script step? Why can't they all process concurrently?

Note that it works fine if I unset all async flags, so it seems to me that this is related to the job executor.

What I concluded is that Activiti expects a job execution to be relatively short, but it's not a really satisfying answer.

I'm using Activiti 5.22 , deployed in Tomcat7 (process deployed in the explorer and launched via the REST API).

1 Solution

Accepted Solutions
daisuke-yoshimo
Senior Member

Re: Instances hang with concurrency

Jump to solution

If you want to increase the number of jobs to be executed concurrently, you should change asyncExecutorCorePoolSize and asyncExecutorMaxPoolSize.
https://github.com/Activiti/Activiti/blob/master/modules/activiti-engine/src/main/java/org/activiti/...

The setting of asyncExecutorCorePoolSize is the thread pool size to execute async job.
Because asyncExecutorCorePoolSize' initial value is 2 and your process sleep, the two process's scripts of your five process occupy the thread pool.

View solution in original post

3 Replies
daisuke-yoshimo
Senior Member

Re: Instances hang with concurrency

Jump to solution

If you want to increase the number of jobs to be executed concurrently, you should change asyncExecutorCorePoolSize and asyncExecutorMaxPoolSize.
https://github.com/Activiti/Activiti/blob/master/modules/activiti-engine/src/main/java/org/activiti/...

The setting of asyncExecutorCorePoolSize is the thread pool size to execute async job.
Because asyncExecutorCorePoolSize' initial value is 2 and your process sleep, the two process's scripts of your five process occupy the thread pool.

malizor
Member II

Re: Instances hang with concurrency

Jump to solution

Thank you for your answer.

As explained in my question, I already modified these settings. But your comment made me double check and I noticed the settings were not taken into account because of a missing line in my conf file.

So that's all good. Now I'm going to fine-tune those parameters for my actual use case.

daisuke-yoshimo
Senior Member

Re: Instances hang with concurrency

Jump to solution

I'm sorry that I don't know how to set asyncExecutorCorePoolSize in activiti-explorer.

I tested your process by customizing ActivitiEngineConfiguration.class.

  @Bean(name="processEngineConfiguration")

  public ProcessEngineConfigurationImpl processEngineConfiguration() {

      SpringProcessEngineConfiguration processEngineConfiguration = new SpringProcessEngineConfiguration();

      processEngineConfiguration.setAsyncExecutorCorePoolSize(100);

      processEngineConfiguration.setAsyncExecutorMaxPoolSize(2000);