Glassfish Thread Pool, Acceptor Threads, HTTP Max Connections

10,022

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.

Share:
10,022
Kenshin
Author by

Kenshin

Updated on July 25, 2022

Comments

  • Kenshin
    Kenshin almost 2 years

    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 :

    enter image description here

    HTTP:

    enter image description here

    Transport TCP:

    enter image description here

  • Kenshin
    Kenshin over 8 years
    malaguna, is it possible for you to give a pictorial representation for your explanation ? that would help me to understand the internal mechanism.
  • Kenshin
    Kenshin over 8 years
    queue for every client?. What does that mean?. Lets say 5 simultaneous requests coming, each one from different client. So you mean to say that there will be 5 queues waiting to be served.Each queue length 4096?
  • malaguna
    malaguna over 8 years
    Sorry for the confusion, I've just re-read and it is not very clear. With every client I meant every listener, not every person accessing your web app, sorry for the inconvenience. That's why I put listen socket in reference to listeners. between parenthesis, but it is a bit confusing. To clarify, please read this: blogs.oracle.com/binublog/entry/… first paragraph is very clarifying.
  • Kenshin
    Kenshin over 8 years
    so, concurrently, an http listener can handle 4096 requests simultaneously? or it depends on thread pool count ?. I am assuming all requests are put in to this queue and if I have 500 as the thread pool count, first 500 requests are simultaneously fetched from this queue and start processing, is that what it means ?
  • malaguna
    malaguna over 8 years
    An HTTP Listener can hold a number of Max Connections requests, that are waiting to be processed for free threads of the pool, so you are right. But be careful that processing is not simultaneously but instead concurrently ... it is not the same.