<div dir="ltr">Is this valid for Wildfly? (I am using 8.2.1) <div><br></div><div>From the previous replies, I understood that the <span style="font-size:12.8px">ServletExtension could be used for embedded Undertow not for Wildfly. Anyway, I gave it a try, but still having Wildfly using </span><span style="font-size:12.8px">task-max-threads and io-threads parameters </span><span style="font-size:12.8px">from (subsystem=io/worker=default/).</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">To test this solution, I created a simple wepapp with one simple Servlet and my </span><span style="font-size:12.8px">ServletExtension.</span><span style="font-size:12.8px">handleDeployment</span><span style="font-size:12.8px"> </span><span style="font-size:12.8px">is executed by the Wildfly.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Thanks</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 17, 2015 at 3:01 PM, Stuart Douglas <span dir="ltr">&lt;<a href="mailto:sdouglas@redhat.com" target="_blank">sdouglas@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Like I said, you can use any thread pool you want if you modify it using a ServletExtension.<br>
<br>
Code looks like:<br>
<br>
<br>
public class MyExtension implements ServletExtension {<br>
<br>
    @Override<br>
    public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext servletContext) {<br>
       Executor myThreadPool = {my thread pool};<br>
       deploymentInfo.setExecutor(myThreadPool);<br>
    }<br>
}<br>
<br>
Then add a META-INF/services entry for the extension.<br>
<span class="im HOEnZb"><br>
Stuart<br>
<br>
----- Original Message -----<br>
&gt; From: &quot;Mohammed ElGhaouat&quot; &lt;<a href="mailto:melghaouat@gmail.com">melghaouat@gmail.com</a>&gt;<br>
</span><span class="im HOEnZb">&gt; To: &quot;Stuart Douglas&quot; &lt;<a href="mailto:sdouglas@redhat.com">sdouglas@redhat.com</a>&gt;<br>
&gt; Cc: &quot;Jason Greene&quot; &lt;<a href="mailto:jason.greene@redhat.com">jason.greene@redhat.com</a>&gt;, <a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
</span><div class="HOEnZb"><div class="h5">&gt; Sent: Wednesday, 14 October, 2015 12:22:20 PM<br>
&gt; Subject: Re: [undertow-dev] Resizing undertow thread pool size dynamically<br>
&gt;<br>
&gt; Hello,<br>
&gt;<br>
&gt; I would like to share with you some more details about our situation. We<br>
&gt; are using some big machines that are shared by many software(many Wildfly<br>
&gt; instances, Databases, ERPs ..) If i don&#39;t set pools sizes i end up with big<br>
&gt; pools as the default size is dependent on the number of CPU cores and out<br>
&gt;  system administrator is complaining about the OS spending time checking if<br>
&gt; the threads have something to do and this impact the other softwares<br>
&gt; installed on the same machine. If I set a small pool size which could<br>
&gt; sufficient in the 90% of time, i am afraid that  Wildfly couldn&#39;t handle<br>
&gt; the 10% of time when the applications are used by a large number of user.<br>
&gt;<br>
&gt; Is there any workaround or are you planning to let the user to set a<br>
&gt; specific ThreadPoolExecutor ? so we can evict idle threads<br>
&gt;<br>
&gt;<br>
&gt; Thanks,<br>
&gt;<br>
&gt; Mohammed.<br>
&gt;<br>
&gt;<br>
&gt; On Wed, Aug 12, 2015 at 11:03 AM, Mohammed ElGhaouat &lt;<a href="mailto:melghaouat@gmail.com">melghaouat@gmail.com</a>&gt;<br>
&gt; wrote:<br>
&gt;<br>
&gt; &gt; I am using Wildfly.<br>
&gt; &gt;<br>
&gt; &gt; Thanks,<br>
&gt; &gt;<br>
&gt; &gt; Mohammed.<br>
&gt; &gt;<br>
&gt; &gt; On Wed, Aug 12, 2015 at 10:55 AM, Stuart Douglas &lt;<a href="mailto:sdouglas@redhat.com">sdouglas@redhat.com</a>&gt;<br>
&gt; &gt; wrote:<br>
&gt; &gt;<br>
&gt; &gt;&gt; Are you using Wildfly or embedded Undertow?<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; If it is the later you can just use<br>
&gt; &gt;&gt; io.undertow.servlet.api.DeploymentInfo#setExecutor to use whatever<br>
&gt; &gt;&gt; executor<br>
&gt; &gt;&gt; implementation you want.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; The reason why most executors don&#39;t reduce the number is because there is<br>
&gt; &gt;&gt; generally very little point, a parked thread is generally very cheap,<br>
&gt; &gt;&gt; while<br>
&gt; &gt;&gt; creating new threads is relatively expensive.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Stuart<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; ----- Original Message -----<br>
&gt; &gt;&gt; &gt; From: &quot;Mohammed ElGhaouat&quot; &lt;<a href="mailto:melghaouat@gmail.com">melghaouat@gmail.com</a>&gt;<br>
&gt; &gt;&gt; &gt; To: &quot;Jason Greene&quot; &lt;<a href="mailto:jason.greene@redhat.com">jason.greene@redhat.com</a>&gt;<br>
&gt; &gt;&gt; &gt; Cc: <a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
&gt; &gt;&gt; &gt; Sent: Wednesday, 12 August, 2015 6:19:11 PM<br>
&gt; &gt;&gt; &gt; Subject: Re: [undertow-dev] Resizing undertow thread pool size<br>
&gt; &gt;&gt; dynamically<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; We are using the servlet API and I am referring to worker pool. Simply<br>
&gt; &gt;&gt; we<br>
&gt; &gt;&gt; &gt; don&#39;t want keeping bunch of idle threads in the JVM consuming some<br>
&gt; &gt;&gt; resources<br>
&gt; &gt;&gt; &gt; without doing any thing useful.<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; So with the bounded queue executor, when the value of the<br>
&gt; &gt;&gt; task-max-threads<br>
&gt; &gt;&gt; &gt; parameter is reached, the number of threads in the worker pool couldn&#39;t<br>
&gt; &gt;&gt; be<br>
&gt; &gt;&gt; &gt; decreased ?<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; Thank you.<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; Mohammed.<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; On Tue, Aug 11, 2015 at 9:50 PM, Jason Greene &lt; <a href="mailto:jason.greene@redhat.com">jason.greene@redhat.com</a><br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; wrote:<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; &gt; On Aug 11, 2015, at 4:42 AM, Mohammed ElGhaouat &lt;<br>
&gt; &gt;&gt; <a href="mailto:melghaouat@gmail.com">melghaouat@gmail.com</a> &gt;<br>
&gt; &gt;&gt; &gt; &gt; wrote:<br>
&gt; &gt;&gt; &gt; &gt;<br>
&gt; &gt;&gt; &gt; &gt;<br>
&gt; &gt;&gt; &gt; &gt; Hi,<br>
&gt; &gt;&gt; &gt; &gt;<br>
&gt; &gt;&gt; &gt; &gt; I would like to know if there is a way to make undertow reducing the<br>
&gt; &gt;&gt; size<br>
&gt; &gt;&gt; &gt; &gt; of the thread pool when the server is less loaded. Is there any<br>
&gt; &gt;&gt; &gt; &gt; parameter(or other way) that make an idle thread die after some<br>
&gt; &gt;&gt; inactivity<br>
&gt; &gt;&gt; &gt; &gt; time ?<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; Are you referring to the worker pool or the I/O pool? The I/O pool is<br>
&gt; &gt;&gt; special<br>
&gt; &gt;&gt; &gt; and is fixed. The worker pool currently uses a JDK ThreadPoolExecutor<br>
&gt; &gt;&gt; with<br>
&gt; &gt;&gt; &gt; an unbounded queue which is a behavior pattern typically desired for web<br>
&gt; &gt;&gt; &gt; servers. That’s not pluggable at the moment, but it could be possible.<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; If you are using the HttpHandler APIs, there is a method on<br>
&gt; &gt;&gt; &gt; HttpServerDispatch that allows you to use your own custom executor for<br>
&gt; &gt;&gt; &gt; blocking tasks (which would allow you to tune the default worker task<br>
&gt; &gt;&gt; pool<br>
&gt; &gt;&gt; &gt; very small). If you are using servlet APIs though that uses the standard<br>
&gt; &gt;&gt; &gt; pools we provide.<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; Is there a particular reason you want to kill idle threads? Threads are<br>
&gt; &gt;&gt; cheap<br>
&gt; &gt;&gt; &gt; unless you are storing massive amounts of thread local data.<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; --<br>
&gt; &gt;&gt; &gt; Jason T. Greene<br>
&gt; &gt;&gt; &gt; WildFly Lead / JBoss EAP Platform Architect<br>
&gt; &gt;&gt; &gt; JBoss, a division of Red Hat<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; _______________________________________________<br>
&gt; &gt;&gt; &gt; undertow-dev mailing list<br>
&gt; &gt;&gt; &gt; <a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
&gt; &gt;&gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/undertow-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/undertow-dev</a><br>
&gt; &gt;&gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt;<br>
</div></div></blockquote></div><br></div>