[rules-users] running multiple instance of rule engine

Swindells, Thomas TSwindells at nds.com
Tue Aug 2 07:24:28 EDT 2011


If you need all the events that are being generated then you need to have a session consume all the events that are being generated.
If you can’t change that requirement then you are probably stuffed.

You should explore partitioning your design in different ways. You may not need all the events generated in which case you could partition it so that different combinations of events go to different destinations. Alternatively you may be able to partition the logic. The first step consumes all the events but only has very simple logic to correlate and reduce the data produced. These correlations could then be farmed out to a stage 2 set of rules which no longer need the event stream or which now only need a subset of the event stream.

Thomas

From: rules-users-bounces at lists.jboss.org [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Neelesh Deo Dani
Sent: 02 August 2011 12:12
To: Rules Users List
Subject: Re: [rules-users] running multiple instance of rule engine

It can be done in single session, if I make sure all the related events always go to a particular host by partitioning input event stream.
Basically, I'm looking for options in a scenario when the number of input events per sec is very large and a single instance/ host won't be able to handle the events. In this case, we need to run multiple instance of rule engine to get the scale.

Thanks,
Neel

--- On Tue, 2/8/11, Wolfgang Laun <wolfgang.laun at gmail.com<mailto:wolfgang.laun at gmail.com>> wrote:

From: Wolfgang Laun <wolfgang.laun at gmail.com<mailto:wolfgang.laun at gmail.com>>
Subject: Re: [rules-users] running multiple instance of rule engine
To: "Rules Users List" <rules-users at lists.jboss.org<mailto:rules-users at lists.jboss.org>>
Date: Tuesday, 2 August, 2011, 4:11 PM
Why don't you do it in a single session?

The overhead created by the procedure you describe is considerable.

And you may run into synchronisation problems such as that the first event has gone to host A, the second one goes to host B, but A hasn't stored the event yet...

-W

2011/8/2 Neelesh Deo Dani <neeleshdev at yahoo.co.in</mc/compose?to=neeleshdev at yahoo.co.in>>
Following example clarifies the question:
I've Event declaration and rule as follows:

declare Event
    @role(event)
    @timestamp(datetime)
    datetime : Date
    name : String
end

rule "Contest"
no-loop
when
    $e1 : Event(name == "event1")
    $e2 : Event(name == "event2", this after $e1)
then
    System.out.println("rule Contest fired");
end
If Event with name "event1" is inserted in the session and after that Event with name "event2" is inserted in the same session, then the temporal operator ("this after $e1" ) will work fine. But, if these two events are inserted in two different sessions ( rule engine running on different host), then it won't work. I'm trying to find a solution for this scenario. One way is to persist the events as well in datastore and whenever any event comes, insert all the previous events also in the session (by fetching from datastore). In this example, when event2 comes (to host2), fetch event1 from datastore and insert it in the session so that temporal operator will work.
Is there any better alternative exists for this scenario?

Thanks,
Neel

--- On Tue, 2/8/11, Abhay B. Chaware <Abhay.Chaware at kpitcummins.com</mc/compose?to=Abhay.Chaware at kpitcummins.com>> wrote:


What do you expect to happen in the scenario mentioned, assuming you are running only 1 rules session? Whatever you expect to happen in this case ( e.g. latest update wins ), you will need to implement in your persistence logic If you are using separate rule engines/instances.

by the way, have you looked at drools grid ? I haven’t used it, but appears to solve a similar problem that you are trying to – distributed computing.

-abhay

________________________________

From: rules-users-bounces at lists.jboss.org</mc/compose?to=rules-users-bounces at lists.jboss.org> [mailto:rules-users-bounces at lists.jboss.org</mc/compose?to=rules-users-bounces at lists.jboss.org>] On Behalf Of Swindells, Thomas
Sent: Tuesday, August 02, 2011 1:47 PM
To: Rules Users List
Subject: Re: [rules-users] running multiple instance of rule engine



I’m not sure I understand the question.

You have two totally independent rule engine on two different servers running with separate JVMs and sessions.

You happen to share data between the two sessions by updating a database but drools has no knowledge of that (they are just java objects which happen to exist) and they certainly aren’t the same object on both servers.

Temporal reasoning and correlation of events will therefore only happen on the facts that are inserted into that processes working memory – there’s no way it could be any way else as it only know about itself, there could be 10 or 0 other processes running it won’t know the difference.



The ideal method is to have an application design where each request is totally independent from all other requests (other than db state) and therefore you do exactly as you have described – there is no other state to share. If you have to share state between them you have a much bigger problem and you probably have to find some other way to partition up the data into separate blocks.



Thomas



From: rules-users-bounces at lists.jboss.org</mc/compose?to=rules-users-bounces at lists.jboss.org> [mailto:rules-users-bounces at lists.jboss.org</mc/compose?to=rules-users-bounces at lists.jboss.org>] On Behalf Of Neelesh Deo Dani
Sent: 02 August 2011 07:42
To: rules-users at lists.jboss.org</mc/compose?to=rules-users at lists.jboss.org>
Subject: [rules-users] running multiple instance of rule engine



Hi,
I need a setup where multiple instance of drools rule engine will be running in different physical hosts. In each host, a web server (API) will be running which will receive an input event, process it and insert into rule engine (session) for rules execution on the same host. I'm using external persistent datastore. The objects will be populated from datastore before inserting into the session. After rule execution if there is any change in the state of the objects the same will be stored back to the datastore. The datastore calls are made outside the rule execution.
In this scenario, if an event comes to one host and another event comes to a different host, how will the temporal reasoning or correlation of events work? What is the recommended way of deploying multiple instance of rule engine for scalability?
Please help in this regard.

Thanks & Regards,
Neel







________________________________

**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster at nds.com</mc/compose?to=postmaster at nds.com> and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road , Staines, Middlesex , TW18 4EX , United Kingdom . A company registered in England and Wales . Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************

This message contains information that may be privileged or confidential and is the property of the KPIT Cummins Infosystems Ltd. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. KPIT Cummins Infosystems Ltd. does not accept any liability for virus infected mails.

-----Inline Attachment Follows-----
_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org<http://mc/compose?to=rules-users@lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users


_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org</mc/compose?to=rules-users at lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users


-----Inline Attachment Follows-----
_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org</mc/compose?to=rules-users at lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110802/1e032ba1/attachment.html 


More information about the rules-users mailing list