Hi,
> 1. Is it okay to use a single, long-lived stateful session, do we need to halt and restart it occasionally to clear up the drools memory?
It's okay to have a single, long-lived stateful session. But you should expire (@expires) events and delete facts which are no longer needed. If you keep adding events/facts without expiring/deleting, it would lead to out of memory.
Anyway, I recommend to monitor the heap under your long-run test.
> 2. Is is acceptable to occasionally insert new packages in the session kbase while processing events in parallel? Adding a package takes around a few hundred milliseconds on a small ruleset, but I don't know how to measure the actual internal downtime
You can incrementally update a kbase using KieScanner.
> 2. The RHS of the rules does not directly modify the working memory by inserting or removing facts, but it may be quite time-consuming, because it can trigger HTTP calls. I'm not sure whether Drools can execute RHS in separate threads or if we should do it manually? In such case, is the "kcontext" variable thread-safe? I pass this variable to java components involved in RHS to get information about current match.
You need to do it manually. kcontext state is changed by an engine thread so it's not thread-safe. You should extract the information from kcontext and give it to the separate thread.
> Additionally, we have activated multithreadEvaluation (that seems relevant since our rules are independent for now), but the engine logs the following message at startup:
> "The rete network cannot be partitioned: disabling multithread evaluation".
> We are not using salience, agendas or queries, is there any other explanation for this?
The message is raised usually when rules are tightly coupled so cannot be partitioned. But you said "our rules are independent". If you can share a small reproducer, I can check it.
> 3. Metrics samples (i.e. events) usually come in batches of tens to thousands. Is it recommended to insert batches all at once for performance considerations using an atomicAction, or inserting them one-by-one does not make much difference?
Sorry that I'm not sure if it makes much difference. It would be nice to measure the performance in your test environment.
I hope it helps.
Toshiya