I have a server with 48 CPUs hosting a Java EE 7 REST API on TomEE+ 7.0.2.
Some of the APIs are in need of making use of as many CPUs as possible as they run parallelized algorithms. The parallelized portion do not require any database or other resources, just some heavy lifting in a shared double[][] matrix.
I am usually working in EJB contexts, but for this particular instance it is not a requirement (and also preferred not to be).
So far I was using
ExecutorService pool = Executors.newFixedThreadPool(maxThreads);
in order to instantiate an executor, but as this seems to spawn actual threads on operating system level I am not a big fan of it - after some JMeter load testing it even led to a point, where the the whole bash was blocked and I could not even SSH the server any more until hard reboot.
I stumbled upon the concept of "Managed Executor Service", but I cannot find a tutorial / example online in how to make use of that (and also configure that).
Could someone please share thoughts on the following?
a) How to configure a thread pool in TomEE (e.g. via server.xml, context.xml or tomee.xml), code examples would be appreciated?
b) Is there a way to just make use of some default thread pool (and is that clever enough to not need tuning, if no, where could I start out tuning that)?
c) How can I look up the thread pool in Java then - preferred via JDNI lookup?
d) If I once decided to make that resource part of EJB, what would the code for Injection look like?
My application context is specified as "myContext" in server.xml, so if you provide samples could you please indicate how the lookup strings would look like, exactly?
Other than that I have a very plain installation of TomEE+ 7.0.2, I did not touch any configuration so far.
Thank you so much for your help!
Daniel