Archive for July, 2008

WCF Performance Comparison

Friday, July 25th, 2008

Microsoft has made some WCF performance data available on MSDN for a while now. The data shows the performance advantages of WCF over ASMX and other SOA frameworks on the platform. In general, WCF is the stronger performer–good news to all the folks who are currently implementing ILOG Rule Execution Server for .NET.

wcf_perform_graph.gif

If you are deploying RES.NET using IIS 7.0 with Windows Server 2008, then you are no longer limited to the bassicHttpBinding. Moreover, the new architecture allows one to trim down the modules used by IIS–allowing for minimal features for your deployment. You can read about the new architecture here. If you want to read about the top 10 reasons why you should like IIS 7.0, then here is a link to a blog entry from Microsoft.com operations, “The Tasty Morsels Found in Dogfood…

CCB

When Does Complex Event Processing (CEP) Complement a BRMS?

Tuesday, July 22nd, 2008

It’s my pleasure to introduce Pierre-Henri Clouin, an ILOG colleague, for this post on Complex Event Processing (CEP). CEP has emerged as one of the “hot topics” in the rules space over the past 12 months. Pierre-Henri is based in Sunnyvale, California and has spent several months looking at the technical capabilities of the CEP products as well as how they are positioned. His first post provides a nice introduction to the subject matter.

Perso_pix_web_ILOG.JPG

Pierre-Henri Clouin, ILOG

As interest grows in CEP, we have started receiving inquiries about how CEP and BRMS compete with or complement each other. After discussing with customers, prospects, and vendors, and reviewing a wide range of use cases, a few patterns have emerged.

CEP shines when:

  • event data rates are very high, typically in the 100,000s events per second, and with multiple event streams;
  • latency is low, typically in the millisecond range;
  • flat data model, simple data type;
  • a few stable rules/ statements/ queries (a few dozens at most) are deployed for filtering, joins or aggregate computation.

These core capabilities are well documented. For additional details, Mark Tsimelzon’s CEP Complexity Scorecard summarizes them very effectively.

On the other hand, a BRMS addresses three critical needs:

  1. rich rulesets, typically ranging from a few dozens to tens of thousands of business rules;
  2. a complete lifecycle management environment for business rules, empowering technical and business users to author, manage, simulate and retire business rules;
  3. extreme agility with the ability to update business rules in as little as a few minutes.

ILOG BRMS does not compromise on performance either, as have shown benchmarks and actual deployments with demanding customers, such as some of the largest websites, payment networks, underwriters, and telecom operators.

brms+cep.png

The map above sums it up: a CEP engine complements a BRMS for use cases with large data rates, low latency, and rich decision automation and management. The CEP engine pairs down the volume of events and only passes interesting events on to the BRMS to perform a rich decision process. Examples abound, notably in fraud management and national security.

Conversely, CEP overlaps with BRMS at the low end of data rates, latency requirements and rulesets. This is the area where we’ve seen some confusing accounts and claims and where a CEP engine provides limited value on top of a BRMS.

In upcoming posts, we will continue to explore and discuss best practices surrounding BRMS and CEP. We encourage you to reach out to us with related experience and questions.

ILOG Rule Execution Server for .NET (RES.NET) Practices and WCF

Friday, July 18th, 2008

Since the release of ILOG Rules for .NET 3.0 in February of this year I have seen a good number of questions now regarding best practices with RES.NET integration and deployment. In many cases, the question is around what provider to use–Local or Remote. Given the WCF underpinnings, is there anything one should think about that would affect performance? The short answer is yes. Below are some general facts and guidelines that should be understood and followed:

1. The RES.NET execution API wraps WCF by dynamically generating the proxy client (ChannelFactory) and exposes a limited set of options that we must do in our client code. This pattern is used regardless of how you are invoking the API–local or remote.

2. In the case of the local invocation, the execution API spawns a ServiceHost object programmatically in the background. This is a lightweight service running within managed code and shares the same process that launched it. When this is done, the ServiceHost spawns its own thread pool using the .NET library and is built into WCF.

3. If your project is a thick client (.NET managed code) you should cache the session object for reuse—make it a high-level member of the EXE. All threads in the application will in turn point to the ServiceHost that was created.

4. For a managed application or fat client, the most efficient configuration is the local provider. Do not attempt to add your own thread pool or create multiple instances of the session you created on the first invocation of the RES.NET client.

5. If you have an ASP.NET application, you should always deploy RES.NET to IIS and ASP.NET. This is because WCF will share the thread pool with IIS and WCF will reuse the thread for processing the WCF request. This is only the case where both the application and RES.NET share an IIS instance on the same machine. If they are on separate machines, again, you should use the ASP.NET deployment option for RES.NET (this requires the use of the remote provider when using the execution API).

6. Do not use the local provider for ASP.NET applications. This will spawn the ServiceHost and will create an additional thread pool.

7. If you have a class library that is uses RES.NET but need to run in both a fat client and ASP.NET, then you should write a little factory and load the correct provider for the deployment model.

If you would like to start a thread on this topic, post your question or comment to the RES.NET forum (click here for the forum) .

Hope this helps many of you and have fun.

CCB

Business Object Models

Thursday, July 10th, 2008

Understanding the Business Object Model (or BOM as it is affectionately known) is one of the keys to using JRules effectively. In this entry I hope to lay some groundwork for subsequent more in-depth entries on the Vocabulary, Executable Object Models and B2X mapping.

The BOM defines the “entities”, “classes”, “types”, or “concepts” (”things”) that you want to write rules about. It is a powerful and expressive object model in its own right, heavily influenced by the capabilities of the Java object model, but also with features from XML Schema and with annotations to describe domains.

The BOM is serialized into a .bom file using a plain text serialization that looks very similar to Java-style class definitions. For example, if you create a “Hello World” rule project using the Rule Project Wizard and then open the generated BOM in a text editor you will see:

property uuid "_L9byoE4CEd2KE6Zi_qxKvw"
package helloworld;

public class Clock
{
    public static readonly ilog.rules.brl.Time currentTime;
}

The syntax should be pretty familiar to most developers. Note that ilog.rules.brl.Time is another BOM class, defined in the JRules System BOM. The System BOM defines the base classes and primitives that are automatically imported into a user application BOM.

BOM classes are namespaced using package declarations, and aggregated within a BOM Entry. BOM Entries are referenced from a Rule Project’s BOM Path. All the BOM classes from all the BOM Entries on the BOM Path are available to a Rule Project. The analogy with Java classes, packages, JARs and the classpath should be obvious.

Before the BOM can be used to author Business Action Language if-then-else rules or decision tables/trees it must be verbalized. The process of verbalization generates human-readable phrases for the classes, attributes and methods in the BOM. The verbalized BOM is expressed as a Vocabulary which is serialized into a .voc file. For the Hello World project the .voc file looks like this:

# Vocabulary Properties
uuid = _L9akgE4CEd2KE6Zi_qxKvw
helloworld.Clock.currentTime#phrase.navigation = the current time

I.e. the phrase “the current time” has been associated with the static attribute helloworld.Clock.currentTime.

BOM classes create vocabulary Terms while BOM attributes/methods create vocabulary Phrases. The diagram below shows how the text within a Business Rule is first related to the vocabulary, which is mapped onto a BOM.

businessobjectmodel.png

One key point to keep in mind is that the BOM is locale independent — it is an object model created for rule authoring purposes. The vocabulary on the other-hand is locale specific as it contains human-readable text. You can create different vocabularies for the same BOM, allowing you to define how rules should look in English, French or Chinese for example.

A BOM is typically created though a “bottom-up” design process: Java classes or XML Schemas are created by the development team defining the Executable Object Model (XOM). A BOM Entry is then generated from the classes or complex types in the XOM. It is then a simple matter to verbalize the BOM to create a Vocabulary and start writing rules. Because the BOM was generated from a XOM, the rules will be directly executable, using instances of the types defined within the XOM as the source of data for the rule engine.

An alternative use case is to define the BOM using a “top-down” design process - creating the classes within the BOM independent of the XOM. Additional work is then typically required to map the BOM to a XOM for use during execution. This mapping declaration is defined in a B2X file which I will return to in a later post.

The BOM is represented and manipulated using the classes in the ilog.rules.bom package. For example, using the API it is possible to create a BOM from an external data source, such as database tables, UML diagram or even a structured requirements document.

Conclusions

The BOM serves several important purposes:

  • Defines a locale independent object model describing the “things” you want to write rules about.
  • Often the BOM is a simplified and flattened version of the XOM specifically tuned to the requirements of rule authors.
  • Provides the foundation for defining a vocabulary, the locale specific expression of how you want to verbalize the BOM for a single language.
  • Maps onto an Executable Object Model, which will be used during the execution of the rules. As such it serves as a bridge model between the requirements of rule authoring and rule execution.
  • Allows the XOM to evolve independent of the BOM — the Java classes within the XOM may be subject to a traditional development process, with a controlled impact on the business rules.
  • Enables rule authoring and maintenance to be performed in environments without the XOM accessible, such as within Rule Team Server.
  • During rule testing using Rule Scenario Manager, rules are executed directly upon the BOM, and instances of BOM classes can be created from rows in Excel spreadsheets.

This post has only scraped the surface of the capabilities of the BOM, XOM, Vocabulary and B2X. I aim to drill down into some of the details in subsequent posts. Stay tuned!

Emergent Behavior

Wednesday, July 9th, 2008

Two books I have read recently made a surprising connection. The first was the 1972 science fiction novel entitled “Hellstrom’s Hive” by Frank Herbert—the author of the well know Dune series. The premise of the book was that human communities, though extreme in the story, may act collectively in ways that one might call intelligent.

Almost a year later, I found myself reading a book by Steven Johnson titled “Emergence: The connected lives of ants, brains, cities, and software.” I find these two books interesting because they consider human behavior on a macro scale and they address the key point that the collective has its own behavior, tastes, and values.

With the introduction of media, starting with the first news papers, the notion of a feedback loop was introduced to human experience. This established a sort of dialectic between a community as it is and what it might become. Feedback loops also exist in with software. The requirements process needs the feedback loop to ensure features match the market its intended for. Software that fails to have the feedback loop tends to have a short life.

From a Web 2.0 perspective, feedback loops can be used as a tool to solve a larger set of problems that scale beyond the capacity of traditional human organization. Johnson gives several great examples of well-known web sites using feedback to manage everything from fraud to the promotion of solid content. However, all of these examples from the Internet have something in common—they most certainly are using some form of rules technology behind the scenes. Imagine the decentralized behavior of millions of web users on a single site providing, in aggregate, perspective on content, tastes, and enforcement of terms of service. Rules technology provides the right kind of tooling that correlate user behavioral data with policies. In aggregate, it takes the work of the collective and directs it toward something that’s manageable.

There are still companies today that must be organized by traditional means; however, even they can take advantage of emergent behavior. Random remains the most efficient way to load an airplane and so long as the data represents human activity (a loan, a purchase, a claim) rules technology can scale enforcement of policy beyond the performance of most teams. There is still room to mature how best to achieve 100% straight-through-processing in many industries but harnessing the power of the collective remains the only way to solve some business problems at Internet scale.

 (Click here for a link to Johnson’s book)

BRMS Resource Center Makeover

Tuesday, July 8th, 2008

You may have noticed that the BRMS Resource has had a makeover recently, expanding it to cover JRules, Rules for .NET and Rules for COBOL. 6 month trial versions of both JRules and Rules for .NET are now available and the content available to help you evaluate Rules for .NET has been expanded.

Don’t hesitate to send your feedback to the BRMS product managers!

JRules Rule Execution Server Memory Usage

Tuesday, July 8th, 2008

Albin sent me some more benchmark results; an update to the results I published a couple of weeks ago. The initial results were intriguing because of the low heap usage on IBM z/OS, while we only ran tests with the Rule Execution Server using the J2SE and POJO rule sessions. For the second benchmark run Albin therfore tested WebSphere Application Server running on Windows, to provide a point of comparison with the same application server running on z/OS. He also expanded the benchmark to test ruleset execution using IlrContext, providing a measure of the memory overhead of the Rule Execution Server.

JVM Heap Size by Number of Rules (Windows)

The chart below shows the memory requirements for ruleset execution based on 4 scenarios:

  1. Command line application using IlrContext rule engine API
  2. Command line application using Rule Execution Server with J2SE rule session provider
  3. Servlet deployed to IBM WebSphere Application Server using RES with J2SE rule session
  4. Servlet deployed to IBM WebSphere Application Server using RES with POJO rule session

win-heap.png

JVM Heap Size by Number of Rules (z/OS)

The four scenarios described above were also run on z/OS.

zos-heap.png

Comparing Windows vs z/OS Heap Usage

win-zos-main-heap.png win-zos-servlet-heap.png

Conclusions

  1. JVM heap usage reported on z/OS is consistently less than on Windows. For example, using a Servlet deployed to WAS with Rule Execution Server with POJO provider, the memory usage was 17%-21% less than the same configuration running on Windows.
  2. The Rule Execution Server has a heap memory overhead compared to IlrContext of between 3% and 15% depending on configuration and the size of the ruleset.
  3. There is very little difference in heap usage between the Rule Execution Server with J2SE provider and with POJO rule session provider on either Windows or z/OS.

The product overall showed predictable memory usage patterns on both Windows and z/OS with modest heap memory requirements. The highest heap memory reported was 32 MB for a Servlet deployed to WebSphere Application Server using the Rule Execution Server J2SE provider, executing a ruleset containing 528 rules.

Working Memory with ILOG Rule Execution Server for .NET

Monday, July 7th, 2008

Recently I have seen some project requirements where customers have requested the use of working memory with ILOG Rule Execution Server for .NET (RES.NET). Even though RES.NET requires the use of parameters for passing in the XOM (see my white paper on parameters vs working memory in the X-Ray Series) you may still want to use Rete and working memory in a stateless manner.

This can be accomplished by creating a virtual method for each object you intend to assert. In the sample below, I have used the business method wizard on a customer object. You can start the wizard from the BOM view of an object and right click on it:

BOM Menu

I created a method named “Assert” that took no parameters and used the rule context. You need to check “Use rule context” if you want the wizard to pass in the engine reference to the method:

Method Wizard

Next, I added code to the method that calls the assert method on the engine instance:

namespace BusinessObjectModel {
    [ILOG.Rules.BusinessObjectModel.ExtendType(typeof(BusinessObjectModel.Customer))]
    public class CustomerExtender {
        [ILOG.Rules.BusinessObjectModel.Method(UseRuleContext = true)]
        public static void Assert(ILOG.Rules.RuleEngine engine, ILOG.Rules.RuleInstance instance, BusinessObjectModel.Customer customer)
        {
            // TODO: Add Assert implementation
            engine.Assert(customer);
        }
    }
}

The final step requires a new rule that does the assertion:

if
'param customer instance' is not null
then
Assert 'param customer instance'  ;

When using RES.NET, all working memory object instances will be internal to the engine; however, you can still pass out data by assigning instances to your out parameter list. Here is an example:

if
     the age of  the working memory customer instance is more than 21
then
     add the status key "APPROVED" to 'param customer instance' ;
else
     add the status key "DECLINED" to 'param customer instance' ;

Have fun.

CCB