<div dir="ltr"><div><div><div>Wolfgang,<br></div>the code to reproduce is below. I'm hoping to process between 20k and 50k events through Drools per second thus the extreme high-throughput testing. I could settle for a single Drools node handling only say 5K per second IFF I could cluster Drools but I've not yet found a way to distribute workload across an active-active Drools cluster (seems there is no such thing?). <br>
<br></div>Since you're recommendation I've shifted to using Drools 5.3 just FYI:<br><br><br></div><div>### Average.java ###<br>package drools53fusioneval;<br><br>import java.io.IOException;<br>import java.util.Random;<br>
import org.drools.KnowledgeBase;<br>import org.drools.KnowledgeBaseConfiguration;<br>import org.drools.KnowledgeBaseFactory;<br>import org.drools.builder.KnowledgeBuilder;<br>import org.drools.builder.KnowledgeBuilderFactory;<br>
import org.drools.builder.ResourceType;<br>import org.drools.conf.EventProcessingOption;<br>import org.drools.io.ResourceFactory;<br>import org.drools.runtime.StatefulKnowledgeSession;<br>import org.drools.runtime.rule.WorkingMemoryEntryPoint;<br>
<br>class AvgDFEChannel implements org.drools.runtime.Channel {<br><br> @Override<br> public void send(Object o) {<br> System.err.println("Recieved channel message: " + o);<br> }<br>}<br><br>public class Average {<br>
<br> public static void main(String[] args) throws InterruptedException, IOException {<br> KnowledgeBaseConfiguration kbconfig = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();<br> kbconfig.setOption(EventProcessingOption.STREAM);<br>
<br> KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(kbconfig);<br><br> KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();<br> kbuilder.add(ResourceFactory.newClassPathResource("drools53fusioneval/basic.drl"), ResourceType.DRL);<br>
if (kbuilder.hasErrors()) {<br> System.err.println(kbuilder.getErrors().toString());<br> }<br> kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());<br><br> final StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession();<br>
session.registerChannel("heartbeat", new AvgDFEChannel());<br> WorkingMemoryEntryPoint ep01 = session.getWorkingMemoryEntryPoint("ep01");<br><br> new Thread() {<br> public void run() {<br>
session.fireUntilHalt();<br> }<br> }.start();<br><br> Thread.sleep(5000); // give the engine time to get setup<br><br> Server hiwaesdk = new Server("hiwaesdk");<br>
session.insert(hiwaesdk);<br> <br> long LIMIT = 10000;<br> long sentCount = 0;<br> int batchSize = 10000;<br> Random rnd = new Random(System.nanoTime());<br> int temp = 0;<br>
long startTS = System.nanoTime();<br> while (sentCount < LIMIT) {<br> for (int i = 0; i < batchSize; i++) {<br> temp = rnd.nextInt(212);<br> IntEvent evt = new IntEvent (temp);<br>
ep01.insert(evt);<br> sentCount++;<br> }<br> Thread.sleep (0x1);<br> }<br> double duration = (System.nanoTime() - startTS)/1000000.0;<br> System.out.println(LIMIT +" events generated in "+ duration +" milliseconds");<br>
System.out.println("Last temperature submitted: "+ temp);<br> for (int i = 0; i < 5; i++) {<br> System.out.println ("Sec "+ i +": "+ hiwaesdk.currentTemp +", "+ hiwaesdk.readingCount);<br>
Thread.sleep (1000);<br> }<br> System.exit(0);<br> }<br>}<br><br><br></div><div>### basic.drl ###<br>package drools53fusioneval<br><br>declare IntEvent<br> @role ( event )<br>end<br><br>rule "number rule"<br>
when<br> $e : IntEvent () from entry-point ep01<br> $s : Server (hostname == "hiwaesdk")<br>then<br> $s.currentTemp = $e.data;<br> $s.readingCount++;<br>end<br><br><br></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Thu, May 16, 2013 at 4:25 AM, Wolfgang Laun <span dir="ltr"><<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
What you describe is definitely not "expected behaviour" - it's more<br>
like that race condition (or another one) already being in 5.3. Posting<br>
your code might be a good idea ;-)<br>
-W<br>
<div><div class="h5"><br>
On 16/05/2013, Jason Barto <<a href="mailto:jason.p.barto@gmail.com">jason.p.barto@gmail.com</a>> wrote:<br>
> I've been working to load test Drools 5.3 to determine if its a fit for a<br>
> project. As part of the test I programmatically insert events as rapidly<br>
> as possible; an example, my earlier test inserted 10k events in about<br>
> 300ms. There is currently a single rule which reads the event and stores<br>
> the event's value into the only fact in Drools. I'm very happy to report,<br>
> and I'm sure it will be no surprise to anyone, that the engine processes<br>
> all the events in roughly 1 sec. However I have noticed that any large<br>
> number of events (~>1000) usually sees that a small number of events don't<br>
> get processed. I think after 10k events as many as 7 appear to have gone<br>
> unprocessed. If 100 events are inserted, rather than 10k, no events get<br>
> disregarded. Being new to Drools I can easily accept that my java code or<br>
> DRL code is off or unoptimized in some way. However not knowing how Drools<br>
> does its magic I'm currently inclined to think that Drools gets swamped<br>
> (10k in 300ms is a lot) and a few events get dropped so Drools can keep<br>
> operating. Is this a known or expected behavior from Drools? If not I am<br>
> happy to post my code, it is similar to the other code sets I've posted in<br>
> the last few days. I'm still new to Drools and trying to learn its behavior<br>
> so any insight or enlightenment is greatly appreciated.<br>
><br>
> Sincerely,<br>
> Jason<br>
><br>
</div></div>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br></div>