<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br></div><div><br>On Jul 8, 2016, at 8:07 AM, Chandru &lt;<a href="mailto:chandru.in@gmail.com">chandru.in@gmail.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">So having separate pools allows HTTP requests to be parsed and queued for processing even if all workers are blocked on JDBC calls, but their processing still waits until worker threads are available. With just a large IO pool even HTTP parsing will be blocked when all threads are blocked on JDBC.</div></div></blockquote><div><br></div><div>Yes but there is another major drawback. When you block an I/O thread you don't just block one connection, you block total connections / N, where N is the size of your I/O pool. So even if you make a pool size of say 50, if you have 1000 connections, then 20 connections are stuck making no progress you spend doing JDBC calls.&nbsp;</div><div><br></div><div>With a separation of IO and worker, even if almost everything ends up in the worker, the server can still process a big chunk of activity in a non blocking fashion. Momentary idle connections, which is frequent considering most client activity is half duplex can be managed without dedicated threads. Also a great deal of server processing such as http processing, routing, redirection, proxying, etc can be done&nbsp;</div><div><br></div><br><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>Have I got that right or am I missing other drawbacks?</div><div><br></div><div>Yes, I understand that having more threads then maximum active connections in pool is futile.<br><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature">--<br>Chandra Sekar.S</div></div>
<br><div class="gmail_quote">On Fri, Jul 8, 2016 at 6:28 PM, Bill O'Neil <span dir="ltr">&lt;<a href="mailto:bill@dartalley.com" target="_blank">bill@dartalley.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Basically the IO threads will open and manage the socket then push the request into a queue for the workers. You can have 1000 HTTP requests queued up to a worker thread pool that only has 10 threads (plus the 4-8 IO threads). With the thread per request model you would need 1000 threads. How you configure it all depends on the type of work that needs to be done. Maybe you want a larger worker thread pool maybe you want a smaller one. The benefit of splitting them out is you get more control.<div><br></div><div>Also keep in mind you should probably be using a JDBC connection pool. If you have 1000 threads fighting over the limited number of JDBC connections it will cause more contention than a much smaller number of worker threads. JDBC connection pools generally have a much lower max number of connections than the number of requests your web server accepts.</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 8, 2016 at 8:46 AM, Chandru <span dir="ltr">&lt;<a href="mailto:chandru.in@gmail.com" target="_blank">chandru.in@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Given every request requires a blocking IO call through JDBC, doesn't using worker pool still boil down to thread per request, as requests will be queued when all threads in the worker pool are blocked on JDBC?<br><div class="gmail_extra"><br clear="all"><div><div data-smartmail="gmail_signature">--<br>Chandra Sekar.S</div></div><div><div>
<br><div class="gmail_quote">On Fri, Jul 8, 2016 at 6:10 PM, Bill O'Neil <span dir="ltr">&lt;<a href="mailto:bill@dartalley.com" target="_blank">bill@dartalley.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">The cost of switching threads is fairly negligible. If you are concerned about that level of performance then you are more likely to run into issues using the on thread per connection model. If you use the 1 thread per connection model you can only have that number of HTTP clients connected to your web server at any given time. However with the IO / Worker thread model you can have a low number of IO threads that accept a very large number of concurrent connections which then queue up all of the blocking requests for the workers to handle.<div><br></div><div>The thread per request model is like going back in time to tomcat days where every webserver gets configured with hundreds to thousands of threads.</div><div><br></div><div>However if you don't have a higher number of concurrent users it realistically shouldn't matter which way you choose. Just keep in mind the thread per request model doesn't scale as far when you have blocking work.</div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 8, 2016 at 8:31 AM, Chandru <span dir="ltr">&lt;<a href="mailto:chandru.in@gmail.com" target="_blank">chandru.in@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">My line of thought was, if every request requires a blocking DB call, why incur the cost of switching threads within a request, if I can instead simply increase the number of IO threads without any adverse effect.<br><div class="gmail_extra"><br clear="all"><div><div data-smartmail="gmail_signature">--<br>Chandra Sekar.S</div></div><div><div>
<br><div class="gmail_quote">On Fri, Jul 8, 2016 at 5:54 PM, Bill O'Neil <span dir="ltr">&lt;<a href="mailto:bill@dartalley.com" target="_blank">bill@dartalley.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">This is exactly what the worker thread pool is built for why would you want to use the IO threads instead? The IO threads are for reading / writing to the socket of the HTTP request. All blocking operations SHOULD be dispatched to worker threads.</div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Fri, Jul 8, 2016 at 8:20 AM, Chandru <span dir="ltr">&lt;<a href="mailto:chandru.in@gmail.com" target="_blank">chandru.in@gmail.com</a>&gt;</span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><span style="font-size:12.8px">If I have a HTTP service where every request requires a blocking JDBC call, is it acceptable to increase the number of IO threads to a large value (say, 10*cores) instead of dispatching to worker thread pool on each request?</span><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Will configuring such a large number of IO threads lead to any adverse effect on throughput or latency?</div><div style="font-size:12.8px"><br></div><div><div data-smartmail="gmail_signature">--<br>Chandra Sekar.S</div></div>
</div>
<br></div></div>_______________________________________________<br>
undertow-dev mailing list<br>
<a href="mailto:undertow-dev@lists.jboss.org" target="_blank">undertow-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/undertow-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/undertow-dev</a><br></blockquote></div><br></div>
</blockquote></div><br></div></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>undertow-dev mailing list</span><br><span><a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a></span><br><span><a href="https://lists.jboss.org/mailman/listinfo/undertow-dev">https://lists.jboss.org/mailman/listinfo/undertow-dev</a></span></div></blockquote></body></html>