[Mondrian] Multi-threading SQL execution

michael bienstein mbienstein at yahoo.fr
Tue Feb 13 17:07:52 EST 2007


The reason that threads shouldn't be created in Servlets is conceptually simple.  Servlets run in a managed environment.  The control over the usage of system resources should be handled by the environment without interference from applications being managed.  Threads are one of those resources.  To give an idea of this, there is actually no restriction on the number of Threads you create in Java.  However if you go over 8 threads per CPU you get serious performance degradation because of the switching the CPU has to do between the threads (at least on Windows Sun JDK 1.4).  So it's better if you set up your application server and configure how many threads get used for all the applications in the same JVM and no application changes this.

More generally, Java has very bad semantics for enforcing this sort of control over system resources.  Consider memory.  I didn't know that Java 5 allowed some control over this as Richard has shown us recently.  Look at the problems though: Derby runs in the same JVM as Mondrian and all of a sudden we get lots of failures because we are told that we're running out of memory.  How can you limit how much memory a WAR can use?  You can't.  With File access you probably could do it with a custom SecurityManager.  With Threads that's probably true too, but no major app server does it.

The second reason has nothing to do with Mondrian.  EJB 1 and 2 focussed on being able to call business logic without worrying about where that logic was implemented.  It could be in a different JVM or even on another computer.  Using threads (or static variables) is therefore forbidden even though if you know you are only running locally then it will still all work.

Lastly, I know commercial BI software that *breaks* this rule and launches a thread in a Servlet init() method.  It is truly astounding how many bad things pop up when the language or framework doesn't constrain you.


PS: Congrats on 2.3 feature complete.  Really happy to see cache flushing in there.  But did Bart's bug on virtual cube get fixed?  I'm really curious as to what causes it.


Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! 
Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pentaho.org/pipermail/mondrian/attachments/20070213/f1260beb/attachment.html 

More information about the Mondrian mailing list