The Business Process profile of WSO2 Enterprise Integrator (WSO2 EI) comes with an embedded H2 database as the BPEL engine's persistence storage, along with other configurations suitable for a development environment. It is recommended that some of these configurations be changed when moving to production, depending on the number of requests the Business Process profile is going to handle per second, your auditing and monitoring requirements, performance requirements and nature of your processes.
The following sections describe some of the key points to note when tuning the Business Process profile:
Configure an external database server such as MySQL as the persistence storage instead of embedded H2 database. Although a slight performance gain can be experienced when using simple BPEL processes with H2 database, it cannot handle multiple concurrent requests and complex processes with the same efficiency.
JDBC connections are useful when your application requires high throughput.
The Business Process profile has three engines; Apache ODE BPEL processor, HumanTask engine and Activiti BPMN engine. These engines are tightly coupled with the database layer and their function is to persist instance data into the database. Therefore, for the Business Process profile to function properly, you need to allocate enough database connections for datasource configurations.
Business Process profile datasource
Both Apache ODE BPEL processor and HumanTask engine share same Business Process profile datasource and database connections. Therefore, we generally recommend allocating 50% of database connections for each engine for an application running with both BPEL and HumanTask.
For example, if you have a total 100 database connections for a BPEL and HumanTask application, you can use up to 50 database connections for the ODE engine and leave the rest of the database connections for HumanTask operations. If you have only BPEL in your application, you can allocate many more database connections for the ODE engine.
Configure the Business Process profile datasource by editing the
<EI_HOME>/wso2/business-process/conf/datasources/bps-datasources.xml file and changing the
maxActive value .
Execution of each BPMN process instance makes multiple database calls. Therefore, when executing multiple process instances by concurrent threads (i.e., users), multiple database connections are used. Accordingly, the database connection pool has to be configured to provide the required number of connections based on the expected maximum concurrent process executions. This can be configured by setting the
maxActive parameter in the
<EI_HOME>/wso2/business-process/conf/datasources/activiti-datasource.xml file. To avoid failures that may occur due to the congestion for db connections,
maxActive should be equal to the expected number of concurrent process executions. However, lesser number of connections may be sufficient depending on the properties of executed process models (i.e., number/type of tasks) and the behavior of processes (i.e. presence of timer events, reaction time of process participants). If the database connection pool size (i.e.,
maxActive) has to be reduced, it has to be done based on load tests with actual process models and expected process behaviours.
Maximum allowed connections for the database connection pool (i.e.,
maxActive) should not exceed the maximum allowed connections (i.e., DB sessions) for the database server. In addition, if the database server is shared with the BPEL runtime or other server, make sure sufficient number of sessions are available for all shared servers. For example, if BPMN connection pool needs 100 connections and BPEL connection pool needs 50 connections, and if it is expected to have peak BPMN and BPEL loads at the same time, the number of database sessions should be at least 150.
Configure the Activiti datasource by editing the
<EI_HOME>/wso2/business-process/conf/datasources/activiti-datasources.xml file and changing the following.
Also note that, even if you have allocated higher number of database connections for datasources, the performance might not increase as expected. One reason for this could be that there are not enough database sessions from the database side. If that is the case, you need to increase the number of database sessions from the database side.
ODE scheduler threads
ODE scheduler threads are useful when your application requires high throughput.
In the ODE engine, every scheduler thread is associated with a database connection. So the rule of thumb is; the number of ODE scheduler threads should be less than or equal to number of database connections allocated for the ODE engine. If this is not followed, some threads may not work properly as they cannot acquire a database connection to work. For example, in an application that uses both BPEL and HumanTask, if you have a total 100 database connections, you can allocate 50 threads for the ODE scheduler. This will guarantee that at a given time, only 50 database connections are acquired by the ODE engine.
Configure this by adding the following to the
<EI_HOME>/wso2/business-process/conf/bps.xml file if it is not specified already.
Multi-threaded HTTP connection manager
Configure multi-threaded HTTP connection manager connection pool settings to suit your BPEL processes. Typically, the HTTP connection manager should be configured to be in sync with the concurrent HTTP connections in the Business Process profile. This is necessary when you have a lot of internal or external service invocations.
There are two configurations in HTTP connection manager. One is
maxTotalConnections and the other is
maxConnectionsPerHost. The values for these depend on the number of concurrent requests that the Business Process profile needs to handle, and the number of external service calls per process instance. Also, if your processes do a lot of service invocation to localhost (or a particular host), then it is necessary to increase the
<EI_HOME>/wso2/business-process/conf/bps.xml file to set specific values as shown below.
This configuration is relevant when partner services take more time to respond. When partner services are slow or take more time to respond, the callee BPEL process's invoke activity fails due to message exchange timeout. By You can increase the timeout values to avoid these kind of failures. Also note that, slow partner services slow down the entire BPEL process. This causes client application timeout. Therefore, you need to increase the timeout interval for client applications. To do this, configure the
<EI_HOME>/wso2/business-process/conf/bps.xml file and the
<EI_HOME>/wso2/business-process/conf/axis2/axis2.xml file as shown below.
Here you must increase the default values for message exchange timeout and external service invocation timeout. Also set the
SO_TIMEOUT parameter and
CONNECTION_TIMEOUT parameter in HttpSender. Increase the timeout value from the default value to 10 minutes.
HumanTask caching is important when you have to deal with a large user store. HumanTasks are tightly coupled with users and user roles/groups. Because of this, the Business Process profile does many user store lookups for HumanTask operations. These user store calls can take a considerable amount of time when the user store is large or located remotely. This degrades the performance of the entire HumanTask engine. Caching user and role lookup data at the Business Process profile side reduces these remote user store calls and improves the overall performance of the HumanTask engine.
Enable HumanTask caching in the
Number of HumanTask scheduler threads
This is relevant when you are not using HumanTask deadline/escalation. HumanTask deadline and escalation are scheduled tasks that are executed by the HumanTask scheduler. By default, 50 threads are allocated to the HumanTask scheduler. If you are not using deadline/escalations, you can configure this value to a lower value such as 5. This will utilize idle threads in the Business Process profile. Note that, you cannot set this to 0, because the HumanTask engine has several internal scheduled tasks to run.
Configure this value in the
BPEL process persistence
Configuring BPEL process persistence is recommended. If a process is implemented in the request-response interaction model, use in-memory processes instead of persistence processes. This decision mainly depends on the specific business use-case.
Use process-to-process communication. This reduces the overhead introduced by additional network calls, when calling one BPEL process from another deployed in the same Business Process profile instance.
Configure event-filtering at process and scope level. A lot of database resources can be saved by reducing the number of events generated.
Take precaution when deploying the Business Process profile in virtualised environments. Random increases in network latencies and performance degradations have been observed when running the Business Process profile on VMs.
Process hydration and dehydration
One technique to reduce memory utilization of the Business Process profile is to process hydration and dehydration. You can configure the hydration/dehydration policy in the
<EI_HOME>/wso2/business-process/conf/bps.xml file or define a custom hydration/dehydration policy.
The following example enables the dehydration policy and sets the maximum deployed process count that can exist in memory at a particular time to 100. The maximum age of a process before it is dehydrated is set to 5 minutes.
MaxAge: The maximum age of a process before it is dehydrated.
maxCount: The maximum deployed process count that can exist in memory at a particular time.
For performance purposes, a process can be defined to execute only as in-memory. This greatly reduces the amount of generated queries and results in less load on the database. Both persistent and non-persistent processes can cohabit in the Business Process profile.
Following is an example of declaring a process as in-memory by adding an in-memory element in the
Configuration details for these optimisations are supported by Apache ODE, but configuration is different from the WSO2 EI Business Process profile.
BPMN performance tuning
The BPMN runtime frequently accesses the database for persisting and retrieving process instance states. Therefore, performance of BPMN processes depends heavily on the database server. In order to get best performance, it is recommended to have a high speed network connection between BPS instances and the database server.
BPMN runtime uses a database based ID generator for allocating IDs for all persisted entities. In a highly loaded clustered scenario (i.e., multiple Business Process profile instances with a shared database), database transaction failures may occur if two Business Process profile instances try to allocate IDs at the same time. This can be mitigated by increasing the number of IDs allocated in a single transaction by setting the
idBlockSize property. Default value of ID block size is 2500. This can be increased by adding the following property to the
processEngineConfiguration bean in the
Another option is to configure the
StrongUuidGenerator instead of using database based ID generator by adding the following property to the
processEngineConfiguration bean in the