On Thu, Oct 15, 2009 at 10:40 AM, phi6 <span dir="ltr"><<a href="mailto:phidinh6@gmail.com">phidinh6@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5"><br>
</div></div>Thanks for that Iain, does that mean however you end up with Thread per<br>
connection anyway (albeit indirectly) which is what I was trying to get away<br>
from in the first place?<br></blockquote><div><br></div><div>By leaving Netty to decide how to use the thread pools you provide, and using a separate pool for processing requests, Netty will not need to create more threads than are required to handle the load of the open channels. Typically, this will be less than 1 thread per connection.</div>
<div><br></div><div>The thread pool used to process the requests can be any size you like, and it is decoupled from the activity on the channels themselves. Take a look at</div><div><br></div><div><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ThreadPoolExecutor.html">http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ThreadPoolExecutor.html</a></div>
<div><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Executors.html">http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Executors.html</a></div><div><br></div><div>for more information on the options available in creating a thread pool executor. The strategy here is to prevent long-running tasks (or blocking behaviour) from stalling Netty's event-driven architecture, while also giving you control over how many threads are used in processing the requests, once they have been decoded from the wire. If in doubt, a cached thread pool executor is a good choice, until you can get more information from profiling to guide better choices (which would typically be system and architecture specific, so be wary of over-optimising).</div>
<div><br></div><div>Iain</div><div><a href="http://www.onedrum.com">www.onedrum.com</a></div><div><br></div><div><br></div></div>