Pages

Monday, March 3, 2014

Redis Performance Evaluation

Redis is an open source, BSD licensed, advanced key-value store. Recently I came across few projects that support redis as their storage. So I think lets explore it a bit more. 
Evalution of redis becomes more easier as it provides a support of redis-benchmark.

Lets see what was result for me. 

System Details : Core 2 Duo , 32-bit, Centos 6.5.

All operations are performed with no pipeline. 

  • Set Operation Performance:

  • Get Operation Performance

  • LPush Operation Performance

  • LPop Operation Performance


Redis perfomed quite well , but how much the performance will get affected on the use of jedis (java client for redis). That will be discussed in next blog.

Sunday, March 2, 2014

Drools Performance Benchmark

Drools performing well in standalone mode, rate is ~ 114285 records/sec for state-full session and ~4760 records/sec for stateless session. Standalone mode refers to just triggering rules on records. There no integration with camel, spring or any other framework.

Have a look on graph for more details:

Statefull vs Stateless session over 1 rule



Statefull vs Stateless session over 10 rule



Performance comparison on 32 bytes, 64 bytes & 128 bytes java object


Note: Performance is almost same for larger java object the variation is due to limitation of java heap memory of VM

Monday, February 10, 2014

Dynamic Drool.

I recently came across a rule engine called drools . Drool 6.0 is quite different from its previous version. For more information you can have a look here.

I am currently working on a use case scenario in which I want the rules to be updated from my webapp (lets call it a drool-workbench) such that new rules can be applied on new tuple of an input stream without building the source again.

Consider this:

Suppose there is an input stream of tuple1,tuple2 & tuple3, and a rule that can be applied on these tuples.
Now, rule r1 is applied on tuple1 & tuple2. And then we need this rule to be updated with some new conditions. With the help of web-app (drools-wb) the rule r1 can be modified as per need. And then the latest artifact in maven repository can be deployed by "build and deploy" feature of drool-wb. As a new tuple (tuple3) is inserted into the stream, kieScanner will scan the maven repository for latest artifact and modified rule will be triggered on tuple3.

Sample Code:

package com.drool;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.kie.api.builder.ReleaseId;
import org.kie.api.builder.KieScanner;
import sample.sample.Person;

public class Dynamicdrool{
 public static void main(String [] args){

  BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
  String s;

  KieServices ks = KieServices.Factory.get();
  ReleaseId releaseId = ks.newReleaseId("sample","sample","1.0-SNAPSHOT");
  KieContainer kc = ks.newKieContainer(releaseId);
  KieScanner kScan = ks.newKieScanner(kc);

  try
  {
   while((s = in.readLine())!=null && s.length()!=0)
   {
    Person p = new Person();
    p.setName(s);
    kScan.scanNow();
    KieSession ksess = kc.newKieSession("sampleKs");
    ksess.insert(p);
    ksess.fireAllRules();
    System.out.println(p.getName());
   }
  }catch(IOException e){
   e.printStackTrace();
  }
 }
}

Points to remember:
  • Use maven build in your project, to be able to use maven repository.
  • KieScanner plays an important role, and it generally scans for newer versions in repository.
    So use 1.0-SNAPSHOT as version or configure your maven for incremental version.
  • There is a bug with kie-Scanner in 6.0.1-Final build. Either wait for latest release or build repos from master branch