Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] understanding selector threads in Jetty

I, too, would like someone from the Jetty team to answer this. 

Perhaps there is a page describing Jetty's thread management?


On Fri, May 2, 2014 at 6:51 AM, Roland Dragoi <roland.dragoi@xxxxxxxxx> wrote:
Hi,

I am using the embedded Jetty web server (9.13), for which I configure the maximum number of threads in the thread pool (maxThreads). 
By looking into the Jetty code, I noticed that Jetty uses a formula for determining the minimum allowed value for maxThreads = 1 + noConnectors*(1 + noCores/16 + noCores). 
That is, for every configured connector, Jetty allocates a number of 1 + noCores/16 acceptor threads and a number of noCores selector threads.
My problem is that if I use a value for the maxThread property close to the minimum accepted by Jetty, the browser blocks when loading the page. 
By monitoring my application on a machine with 80 cores, I noticed that in the Jetty thread pool there are 6 acceptor threads (of which only one is running at any given time) and 80 selector threads (all of them are running continuously in the selector loop). If I configure the maxThreads to the minimum accepted of 87, I am only left with 1 thread to actually do the work of handling the request and the browser blocks, as many requests stay pending. Of course, I could just increase the maxThreads value until it works, but the memory resources are limited. In my case I only use one connector, but if I will later add a second connector for HTTPS, the number of selector threads will double. Also, Jetty uses by default a number of 200 for the maxThreads property, but I imagine that on a machine with even more cores, my problem will become the default. 
I noticed it is possible to also configure the number of acceptors and selectors for each connector and I intend to try that, but I would like to understand first what they do.  

My question for you is what is exactly that the selector threads do and if such a great number of them is really necessary. 
If I were to decrease their number, is there a recommended ratio between the selector threads and the worker threads? 
 
Thank you for any pointers in this matters!

Roland

_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users



Back to the top