Overview
Thread limit needs to be increased on the launcher configuration when using Jetty with Aurea Monitor Intermediary (AI).
This is needed when you are configuring HTTP listeners for the Intermediary profile from the AMS console, because if you leave the default values for available threads (eg 10 Max Acceptor Threads and 10 Max Selector Threads), then when you reach 10 HTTP listeners and restart the intermediary, it does not start and shows this error:
java.lang.IllegalStateException: Insufficient threads: max=200 < needed(acceptors=100 + selectors=100 + request=1)
Full error:
jvm 1 | 2019-12-20 08:29:25.069:WARN:oejuc.AbstractLifeCycle:main: FAILED org.eclipse.jetty.server.Server@3cb5cdba: java.lang.IllegalStateException: Insufficient threads: max=200 < needed(acceptors=100 + selectors=100 + request=1)
jvm 1 | java.lang.IllegalStateException: Insufficient threads: max=200 < needed(acceptors=100 + selectors=100 + request=1)
Solution
This error occurs because there is a default thread pool limit of 200 on the Jetty server. That limit is reached because each listener thread consumes several threads from Jetty's available thread pool.
You need to increase the max threads limit of Jetty using the steps and formula below:
- Navigate to
$SERVER_HOME\packages
(e.g.C:\AureaMonitor\AureaMonitorServer\packages
). - Extract the jetty.zip and open the etc folder.
- Open the jetty.xml file in a text editor.
- Increase the default value for the jetty.threadPool.maxThreads variable and save the updated file.
<Set name="maxThreads" type="int"><Property name="jetty.threadPool.maxThreads"
Note: The number of threads depends on the number of cores on the machine where AI is running. The max and min thread numbers can be calculated using the below formulas:
deprecated="threads.max" default="200" /></Set>
Min HttpListener Thread = [No. CPU cores] x 16
Max HttpListener Thread = [No. CPU cores] x 64 - Zip the files and folders extracted from jetty.zip (including the updated jetty.xml file) and replace the old jetty.zip file.
- Stop the Intermediary instance and remove the
deploy
folder located in the$AI_Home
directory (AI installation folder). - Start the Intermediary.