w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Is there a way to reuse a knowledge base rather than re-inserting all facts with stateless knowledge sessions?

To be honest, a stateless session just wraps a stateful session and removes some functionality from it (i.e. you can't pop things in and out).

Inserting a lot of facts is generally a slow process. There is no mechanism to load them fast into a new session. Insert-evaluate-retract solutions can be pretty fast, as they enable you to force the engine to balance itself against the initial 10k facts, so additional facts cause minimal re-evaluation.

To be multi-threaded doesn't mean that you need to go stateless. I would recommend just creating a pool of stateful sessions, with your initial 10k facts already inserted. You just need a little bit of extra logic to ensure that whenever one of those base facts is altered, you alter all of the sessions (it doesn't sound like that's happening frequently). Obviously this will make your application a bit more of a memory hog, but it's a simple way of scaling up.

And you don't say how slow it was with stateful sessions. I have taken a Drools application with 30sec response times and got it providing hundreds of responses in less than a second. I don't know how awesome your DRL coding skills are, so as far as I know, it could just be that you need to do some rules re-writes. Maybe that's food for a separate question. :)

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.