Session management

109 views
Skip to first unread message

snow crash

unread,
Feb 9, 2014, 4:48:53 AM2/9/14
to no...@googlegroups.com
Hi all !

I'm playing with nools since... yesterday so please excuse dumb questions :)
I'm looking at a CEP/Rule Engine in node.js to handle large amount of IoT incoming data (imagine temperature, pressure, energy... measurements) and I'm wondering if nools can fit in term of architecture.

Let me explain, if I've got a lot of independent node workers consuming the incoming measurements, would it make sense to have each worker creating a unique nools session at init and then each time data is arriving, assert the fact to the global session ?

I did some tests using a Restify endpoint and :
- having a unique nools session created and asserting data to this session then calling match each time
- getSession()/dispose() each time data is received then assert/match

=> performance is twice better usign a unique session (1000 asserts/s vs. 500 asserts/s) than as many session as facts

So is it the good pattern ? Or is there a better idea (pool of sessions ?)

I understood one unique session may cause memory to grow fastly as it is never disposed but.... if facts are well retracted I guess it is ok ? 

Thanks for any feedback !

matt


Note : Restify POST callback ex using one unique session :

function sendV001(req, res, next) {
  session.assert(new Measurement(req.params.gtwId, req.params.measurementId, req.params.intValue, req.params.ts));
session.match(function(err) {
   if(err){
       console.error(err);
       res.send(503);
   }else{
    console.log("Nb facts in sessions : " + session.getFacts().length);
       res.send(200);
   }
})    
return next();
}
Reply all
Reply to author
Forward
0 new messages