views:

427

answers:

4

I've been having a look at WF Rules Engine and NxBRE and it seems interesting but I'm unsure of how well it will perform in real life scenarios.

The one I have in mind is something like a fact base with between 10 and 100 million facts and rules like:

Object.Field < 5000 AND Object.Field > 1000 AND IsProperty(Object.Field2)

I'm using C# and .NET.

Edit: I haven't make myself clear (totally my fault) :) I have my own rule evaluation system that uses the RETE algorithm itself ... it is quite fast, it can evaluate the 10 million fact scenario in about 10 seconds... how fast are comercial solutions in comaparison?

+4  A: 

The short answer is I would expect a rules engine to outperform an imperative solution once the number of rules exceeds some (I don't know the exact value) threshold value.

The rules part of a rules engine is set of conditions and actions. A single rule is (nearly) functionally equivalent to an if - then statement. The real power of a rules engine shines through due to the declarative nature of the engine.

In a traditional imperative program, you have to code how the logic is evaluated. When using a rules engine, it determines how many of your statements are evaluated. I have only used engines like Jess or CLIPS, which use a rete algorithm to figure out which rules to fire. It is the efficiency of your rules firing algorithm that is going to drive how much more efficient your rules engine will perform over a traditional imperative solution.

The Rete algorithm is designed to sacrifice memory for increased speed. It maintains a network of nodes mapping LHS side patterns to rules. The more rules & facts you have, the better your rete network will outperform your imperative solution, because Rete performance is theoretically independent of the number of rules in the system.

You are planning on a lot of facts. If you plan to have a lot of rules, you may run into memory problems.

Take a look at Martin Fowler's article on rules engines. It's a good and (very) short overview.

There is a lengthy discussion on the Microsoft Business Rules Engine (MS-BRE) adn it's performance compared with Jess & Drools. Several of the points raised underscore why these evaluations are hard.

DaveParillo
Nice answer but ... I haven't make myself clear (totally my fault) :) I have my own rule evaluation system that uses the RETE algorithm itself ... it is quite fast, it can evaluate the 10 million fact scenario in about 10 seconds... how fast are comercial solutions in comaparison?
Jorge Córdoba
So you want to know how YOUR rules engine compares to others available??
DaveParillo
More or less, basically we're redoing it to .NET (it was programmed on Delphi) because the contract with the client specifies all has to be done in .NET. I want to know if a third solution will work as well as the old one.
Jorge Córdoba
Unless you make the details of your engine available (i.e. source code) it's unlikely anyone except you will be able to answer that question. BTW - if I DO answer this question do I get listed as a coauthor on your thesis? ;-)
DaveParillo
Jeje, It's not a thesis, is a real app I just don't want to redo the work again in another language but I'm afraid to develop it against say nxBRe and find out it does perform badly...
Jorge Córdoba
I recommend storing your rules in a language independent medium (clips, or clips-like, or RuleML). Then you isolate yourself from changes in your rules engine. You should do this even if you stick with your existing solution.
DaveParillo
Typically rules engines are evaluated in terms of their rule sets, not their fact databases. Trying to compare facts is very slippery - An engine will typically dynamically add or remove facts as rules are fired. The fact database is rarely constant. If you have 10 million **rules** - all I can say is wow. Good luck with that.
DaveParillo
+2  A: 

One thing to be very aware of is that the WF rules engine is that it actually implements its own parser and, as a result, is somewhat limited in its expressiveness and does have performance considerations since it is pretty much doing string parsing to interpret the rules into code (executable actions) at runtime.

Scott Dorman
+1 and there is some rumor that it's not a faithful rete implementation, but that may be mostly anti-MS FUD.
DaveParillo
+1  A: 

We ran 24 million tests through 1500 rules in seven minutes using JBoss Drools with two JVMs running on pretty darn average servers. That's more than thirty six billion tests to be run if you ran every combination, and most tests have multiple logic choices in them. (Your example has three choices, for example.)

Dean J
+1  A: 

Dave - there isn't a question of whether WF Rules implements a "faithful rete implementation". It doesn't implement Rete. Keep in mind that Rete is simply a specific optimization of forward chaining. There are others optimizations out there.

kreinsch