Glassfish Thread Pool, Acceptor Threads, HTTP Max

2020-05-19 09:10发布

问题:

Please see the attached images, Please help me to understand the relationship between thread pool(max and min thread pool size), acceptor threads and its max connection count and HTTP max connection count.

Thread Pool :

HTTP:

Transport TCP:

回答1:

First I'll give you some official documentation

Thread Pool

The thread pool is the max number of simultaneous requests the server can handle. The server has a queue of connections awaiting to be processed by a thread.

Keep in mind that a thread will be a long the request life. That is, not only when reading HTTP request from socket, or when writing HTTP response to client, but all time it is dealing with business logic, awaiting DB to finish, writing to a log file, sending/receiving WS mehtods, ...

Read: https://docs.oracle.com/cd/E18930_01/html/821-2431/abehk.html

HTTP Max Connections

HTTP Server is listening to clients requests, and every client has an associated connection queue where requests are queuing to be processed by a thread from the Thread Pool.

Here is where live the threads waiting to serve queued requests.

Read: https://docs.oracle.com/cd/E18930_01/html/821-2431/abegk.html

Transport acceptor threads

Is the number that states how many threads can hold your server in accept mode for every listen socket at any time. Oracles documentation recommends to have this number below of number of the numbers of CPU's.

That is, this is the number of sockets that are reading/writing simultaneously. You can think of a direct relation with thread pool, but remember a thread is not only to read/write from/to client, but for processing request too.

Read: http://docs.oracle.com/cd/E18930_01/html/821-2431/gkxjt.html

My Explanation

So, your server will have a queue for every client (listen socket) where there can be no more than Max Connections. This connections will be processed by a Thread Pool and at the same time it can not be more than Acceptor Threads processing/accepted sockets.

If a client request is awaiting more thant Time out it will be rejected. Min Thread Pool ensures you to have a minimun of threads, ready to processing. And Max Connection Count limits the total of listen sockets you can have waiting. If this last limit is exceed, new connections will be rejected.

Hope it helps.