Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change thread pool size in Jetty 9

How can I change thread pool size in embedded Jetty 9? Do we need any specific component for this?

like image 801
Alexander Bezrodniy Avatar asked Aug 30 '13 13:08

Alexander Bezrodniy


2 Answers

From docs:

The Server instance provides a ThreadPool instance that is the default Executor service other Jetty server components use. The prime configuration of the thread pool is the maximum and minimum size and is set in etc/jetty.xml.

<Configure id="server" class="org.eclipse.jetty.server.Server">    <Set name="threadPool">     <New class="org.eclipse.jetty.util.thread.QueuedThreadPool">       <Set name="minThreads">10</Set>       <Set name="maxThreads">1000</Set>     </New> </Set>  </Configure> 

Or

QueuedThreadPool threadPool = new QueuedThreadPool(100, 10); Server server = new Server(threadPool); 
like image 128
rocketboy Avatar answered Sep 19 '22 12:09

rocketboy


As noted, and corrected in the Java code example above, the threadpool is now provided as a constructor argument in Jetty 9 (and later).

The corrected XML example:

<Configure id="Server" class="org.eclipse.jetty.server.Server">      <!-- =========================================================== -->     <!-- Configure the Server Thread Pool.                           -->     <!--                                                             -->     <!-- Consult the javadoc of o.e.j.util.thread.QueuedThreadPool   -->     <!-- for all configuration that may be set here.                 -->     <!-- =========================================================== -->     <Get name="ThreadPool">         <Set name="minThreads" type="int">10</Set>         <Set name="maxThreads" type="int">200</Set>         <Set name="idleTimeout" type="int">60000</Set>         <Set name="detailedDump">false</Set>     </Get>     ... 
like image 20
sprynter Avatar answered Sep 18 '22 12:09

sprynter