Process Deployment Best Practices
The default distribution of WSO2 BPS comes with an embedded H2 database as the BPEL engine's persistence storage along with other settings suitable for development environment. However, it is recommended that some of these configurations be changed when moving to production. Configuration setting may change depending on the number of requests BPS is going to handle per second, your auditing and monitoring requirements, performance requirements and nature of your processes.
The following are the key points to note.
OS-level settings
To optimize network and OS performance, configure the following settings in
/etc/sysctl.conf
file of Linux. These settings specify a larger port range, a more effective TCP connection timeout value, and a number of other important parameters at the OS-level.It is not recommended to useÂ
net.ipv4.tcp_tw_recycle = 1
when working with network address translation (NAT), such as if you are deploying products in EC2 or any other environment configured with NAT.net.ipv4.tcp_fin_timeout = 30 fs.file-max = 2097152 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_tw_reuse = 1 net.core.rmem_default = 524288 net.core.wmem_default = 524288 net.core.rmem_max = 67108864 net.core.wmem_max = 67108864 net.ipv4.tcp_rmem = 4096 87380 16777216 net.ipv4.tcp_wmem = 4096 65536 16777216 net.ipv4.ip_local_port_range = 1024 65535
To alter the number of allowed open files for system users, configure the following settings in
/etc/security/limits.conf
file of Linux (be sure to include the leading * character).* soft nofile 4096 * hard nofile 65535
Optimal values for these parameters depend on the environment.
To alter the maximum number of processes your user is allowed to run at a given time, configure the following settings in Â
/etc/security/limits.conf
 file of Linux (be sure to include the leading * character). Each carbon server instance you run would require up to 1024 threads (with default thread pool configuration). Therefore, you need to increase the nproc value by 1024 per each carbon server (both hard and soft).* soft nproc 20000 * hard nproc 20000
JVM-level settings
If one or more worker nodes in a clustered deployment require access to the management console, you would need to increase the entity expansion limit as follows in the <BPS_HOME>/bin/wso2server.bat
 file (for Windows) or the <BPS_HOME>/bin/wso2server.sh
 file (for Linux/Solaris). The default entity expansion limit is 64000.
-DentityExpansionLimit=100000
External database
Configure an external database server such as MySQL as the persistence storage instead of embedded H2 database. Although slight performance gains 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
JDBC connections are useful when your application requires high throughput.
BPS has two engines; Apache ODE BPEL processor and HumanTask engine. These two engines are tightly coupled with the database layer and their function is to persist instance data into the database. Thus, for BPS to function properly, you need to allocate enough database connections for BPS datasource. Both these engine share same BPS datasource and database connections so 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 upto 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.
Also note that, even you have allocated higher number of database connections for the BPS datasource, performance may 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 database side.
Configure the BPS datasource by editing the <BPS_HOME>/repository/conf/datasources.properties
file and changing the following.
synapse.datasources.bpsds.validationQuery=SELECT 1 FROM DUAL synapse.datasources.bpsds.dsName=bpsds synapse.datasources.bpsds.maxActive=100 synapse.datasources.bpsds.maxIdle=20 synapse.datasources.bpsds.maxWait=10000
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 <BPS_HOME>/repository/conf/bps.xml
file.
<tns:odeschedulerthreadpoolsize>50</tns:odeschedulerthreadpoolsize>
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 BPS. This is necessary when you have a lot of internal or external service invocations.
There are two configurations in HTTP connection manager. One is 'max total connections' and the other is 'max total connection per host'. These settings depend on the number of concurrent requests BPS 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 maxConnectionsPerHost
configuration.
Configure the <BPS_HOME>/repository/conf/bps.xml
 file to set specific values as shown below.
<tns:WSO2BPSxmlns:tns="http://wso2.org/bps/config"> ... <tns:MultithreadedHttpConnectionManagerConfig><tns:maxConnectionsPerHostvalue="20"/><tns:maxTotalConnectionsvalue="200"/></tns:MultithreadedHttpConnectionManagerConfig> ... </tns:WSO2BPS>
TimeOuts
This configuration is relevant when partner services take more time to response. When partner services are slow or take more time to response, callee BPEL process's invoke activity fails due to message exchange timeout. By increasing time will avoid these kind of failures. Also note that, slow partner services will slow entire BPEL process. This will cause to timeout the client application. Thus it is required increase timeout interval for client application. To do this, configure the <BPS_HOME>/repository/conf/bps.xml
 file and the <BPS_HOME>/repository/conf/axis2/axis2.xml
file as shown below.
<tns:MexTimeOut value="600000"/> <tns:ExternalServiceTimeOut value="600000"/>
<transportSender name="http" class="org.apache.axis2.transport.http.CommonsHTTPTransportSender"> <parameter name="PROTOCOL">HTTP/1.1</parameter> <parameter name="Transfer-Encoding">chunked</parameter> <!-- This parameter has been added to overcome problems encounted in SOAP action parameter --> <parameter name="OmitSOAP12Action">true</parameter> <parameter name="SO_TIMEOUT">600000</parameter> <parameter name="CONNECTION_TIMEOUT">600000</parameter> </transportSender>
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
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, BPS does lot of user store lookups for HumanTask operations. These user store calls can take considerable amount of time, if 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 BPS side will reduce these remote user store calls and improve the overall performance of the HumanTask engine.
Enable HumanTask caching in the <BPS_HOME>/repository/conf/humantask.xml
file.
<cacheconfiguration> <enablecaching>true</enablecaching> </cacheconfiguration>
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 for 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 BPS server. Note that, you can't set this to 0, because the HumanTask engine has several internal scheduled tasks to run.
Configure this value in the <BPS_HOME>/repository/conf/humantask.xml
 file.
<schedulerconfig> <maxthreadpoolsize>5</maxthreadpoolsize> </schedulerconfig>
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.
Process-to-process communication
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 BPS instance.
Event filtering
Configure event-filtering at process and scope level. A lot of database resources can be saved by reducing the number of events generated.
Non-visualized environments
Take precaution when deploying WSO2 BPS in virtualized environments. Random increases in network latencies and performance degradation have been observed when running BPS on VMs.
Process hydration and dehydration
One technique to reduce memory utilization of the BPS engine is process hydration and dehydration. User can configure the hydration/dehydration policy in $PRODUCT_HOME/repository/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.
<tns:ProcessDehydrationmaxCount="100"value="true"><tns:MaxAgevalue="300000"/></tns:ProcessDehydration>
- MaxAgevalue: Sets the maximum age of a process before it is dehydrated.
- ProcessDehydrationmaxCount: The maximum deployed process count that can exist in memory at a particular time.
In-memory execution
For performance purposes, a process can be defines as being executed only in-memory. This greatly reduces the amount of generated queries and puts far less load on the database. Both persistent and non-persistent processes can cohabit in WSO2 BPS.
Shown below is an example of declaring a process as in-memory simply by adding an in-memory element in the deploy.xml file.
<processname="pns:HelloWorld2"> <in-memory>true</in-memory> <providepartnerLink="helloPartnerLink"> <servicename="wns:HelloService"port="HelloPort"/> </provide> </process>
Configuration details for these optimizations vary in older BPS versions. Also, these optimizations are supported by Apache ODE, but configuration is different from WSO2 BPS.