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.
Given below are the key points to note:
External Database
Configure an external database server such as MySQL as the persistence storage instead of embedded H2 database. Althogh 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.
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 BPS server.
There are two configurations in Http connection manager. One is 'max total connections' and 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. For example,
<tns:WSO2BPSxmlns:tns="http://wso2.org/bps/config"> ... <tns:MultithreadedHttpConnectionManagerConfig><tns:maxConnectionsPerHostvalue="20"/><tns:maxTotalConnectionsvalue="200"/></tns:MultithreadedHttpConnectionManagerConfig> ... </tns:WSO2BPS>
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.
Process Instance Cleanup
Configure process instance cleanup. A large number of process instance data will be accumulated in the BPEL engine's persistence storage if processes are persisted. Process instance cleanup is used to reduce performance overhead introduced by database size. The process instance cleanup feature can be configured with periodic cleanup tasks based on various process instance properties, to remove data from WSO2 BPS persistence storage.
The 'Schedules' section in bps.xml can be used to configure instance cleanup. The 'Schedules' section can contain multiple 'Schedule' elements with multiple 'cleanup' elements. In each 'Schedule' element, the attribute 'when' states the time that the instance cleanup task gets executed. Time is configured using cron expressions (http://www.quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger). Inside the cleanup element, filter elements can be used with various instance properties, which help select the instance to be deleted.
For example, the following code schedule is configured to initiate a cleanup task at 5:11 PM every day to clean completed process instances.
<tns:Schedules> <tns:Schedule when="0 11 17 * * ?"> <tns:cleanup> <tns:filter><![CDATA[status=completed]]></tns:filter> </tns:cleanup> </tns:Schedule> </tns:Schedules>
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 $CARBON_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>
Note
Note
These best practices are valid for WSO2 BPS 2.1.0 onwards. 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.