Configuring and Optimizing Drools
This section details various improvements that are implemented for Drools optimization and KIE Session pooling.
Drools Optimizations
- ProjectClassLoader: Drools' ProjectClassLoader class leads to thread congestion. A patched version has been provided as a .class file (located in the ruleengine/resources/org/drools/core/common directory).
- ChainedProperties: Drools ships with a ChainedProperties class that excessively reads from a properties file. A patched version has been provided as a .class file (located in the ruleengine/resources/org/kie/internal/utils directory).
Placing the .class files in the resources directory ensures that the platform classloader loads these classes instead of the classes provided in the Drools libraries. The Drools libraries are located in the ruleengine/lib directory.
KIE Session Pooling
Drools ships with a simple Knowledge Is Everything (KIE) session pooling mechanism. KIE session pooling can improve memory consumption because the sessions are reused.
ruleengine.kiesession.pool.enabled=true ruleengine.kiesession.pool.initialcapacity=5 ruleengine.kiesession.pool.keep.only.one.version=true
Optimizing Memory Consumption of Drools KieModules
It is more likely to encounter performance issues related to high memory consumption or potential memory leaks of kieModules when publishing promotion rules and executing kieModules swapping with high concurrency in the cluster deployment mode.
ruleengine.remove.all.previous.versions.kiemodules.in.kierepository=false
The value of this configuration is false by default.
Addressing Infinite Loop Issues in Drools with Timeout Mechanism
When executing evaluations of promotion rules, there are extreme cases where the evaluation process gets stuck in an infinite loop. This occurs when the method doUpdatesReorderRightMemory is invoked within the class RuleNetworkEvaluator of Drools. This can result in excessive CPU consumptions and decreased performance.
drools.rulenetworkevaluator.timeout=10
The default value for the timeout property is set to 10 seconds. It's possible to modify this value to align with the business requirements. It is important to note that in order for the new timeout value to take effect, a server restart is required.