Performance Considerations

Some business rules are invoked frequently, like rules running during approval and import. To preserve the performance of the MDM system, it is important to make sure that the business rules perform well. A business rule runs in a single transaction, so it is also important that it finishes within a short time to avoid optimistic locking errors.

Investigating Business Rule Performance

There are several ways to analyze and monitor business rules.

  1. In the workbench, there is a business rule test option that is typically used during development. To test, right-click on the business rule then select 'Test Business Rule.'

Once this option is selected, the 'Test & Time Business Rule' dialog will display. The 'Test Object' field needs to be populated with any objects that are valid for the business rule.

Select 'Test' with an object selected. Note the timing field. Run a few different items to generate different timings, and analyze the results. The following screenshot shows that the business rule took about 190 milliseconds to complete the business rule for item 21933. Be aware that it might take longer or shorter for other items running the same rule.

  1. Another way to test a business rule is in the Statistics tab of the business rule in the workbench.

The business rule statistics tab displays minimum, maximum, average, and total duration of the business rule as well as the number of invocations per selected period. The period can be configured from a period of an hour to a week.

The following screenshot shows the same business rule which was invoked 95 times during the last seven days. Through these invocations, an average duration of about 4.6 ms was calculated. If the maximum duration value of 48 ms is selected, the workbench will navigate to the record that caused the slowest time to complete.

This method of business rule analysis gives an indication of the business rule performance over a period of time.

  1. The Admin Portal provides the possibility to track and trace business rule performance over a given period. From the Admin Portal, under Activity Dashboard, select Business Rules from the top right dropdown.

The period over which the statistics are gathered can be configured. The dashboard shows the top business rules over the configured period, with:

  • The longest average evaluation time
  • The longest maximum evaluation time
  • The longest total time
  • The number of invocations

This method of business rule analysis gives an indication of the performance of the most demanding business rule over a period of time. It is very important to analyze the business rules stated under 'Total time' since these are the business rules with the longest average evaluation time and the most number of invocations.

  1. There is also an option in the Admin Portal version 8.1 and above to trace business rules. The functionality of the Business Rule Tracing section of the Tools tab is described within the interface itself.

Business rule tracing can be enabled for a limited period. When enabled, detailed trace information will be written to log files available via the Admin Portal 'Logs' tab.

Note: Enabling business rule tracing will have a negative impact on performance. To minimize the impact, it is advised to add as many filters for the tracing configuration as possible.

Click the yellow information icon next to each parameter for a complete description of the parameter / filter and any relevant information for populating it.

When the necessary information has been added, click the 'Activate' button to begin tracing.

Note: Once tracing has been activated, the relevant business rule(s) must be triggered in the system within the time frame defined in the Trace Duration parameter so that the rule is active for tracing. Furthermore, if the system is stopped or restarted, any tracing that was in progress will also be stopped.

Tracing will stop automatically when the specified duration has expired. Alternatively, users can click the 'Stop' button, which is available only when tracing is in progress, at any time to kill the trace prior to completion of the duration.

Performance Recommendations

  • Keep business rule transactions small

Business rules have a transaction, which allows you to write data to the system. However, business rules with long transactions will degrade the performance. Furthermore, the system runs with optimistic locking policy. The longer the transaction, the larger is the probability of introducing an optimistic locking failure when running the business action simultaneously.

  • Avoid the function GetChildren with many nodes

Business rules using calls 'getChildren' on a huge number of children may cause memory problems. The problem is that the 'getChildren' uses an unsafe call that will read all children. It should be changed into using 'queryChildren.'

public List getChildren(final String internalId, final Class wantedChildType, final Manager manager) {
...
   } else if (obj instanceof Product) {
      Product product = (Product) obj;
      children = product. getChildren(); //also works for product overrides, but this action is unsafe.

It is recommended to analyze the business rules and determine if the 'getChildren' function is not used on a selection with more than 10,000 children. If over 10,000 children are expected, change it to the 'queryChildren' function.

  • Use arrays instead of multiple read calls

Business rules repeatedly using calls to the database for large sets of data significantly degrades performance. Instead, use one call to get the data, and push it into arrays and work from there. Minimizing the number of calls to the database aids performance.

When multiple business rules are executed sequentially (e.g., as part of an approval process), and these business rules fetch the same data from the database multiple times, it is beneficial to rewrite the business rules to fetch the data once, and push the data into (multi-dimensional) arrays or local data structures.

  • Consider In-Memory for business rules

In-Memory can improve performance of the business rules. In-Memory provides faster operations on complex data models where business rules navigate references.

Consider using In-Memory when performance improvement on business rules is still required and all previous recommendations on business rules are implemented.