Tomcat maxThreads is config for acceptor threads or Request processing threads

Viewed 409
  1. I follow oracle doc and wonder what is tomcat maxThreads config for? acceptor threads or Request processing threads?

  2. As oracle docs

Request processing threads in a thread pool then pick up connections from the queue and service the requests.

enter image description here

What is pick up do: Does it pop() a connection in queue and process this or request processing thread only listening request from a connection in Connection queue?

Thanks

1 Answers

As explained in the question Tomcat - maxThreads vs maxConnections, the maxThreads attribute is the size of the Executor used to process requests. No more than maxThreads requests will be processed at the same time.

On Tomcat 8.5 and later all connector types also use an acceptor thread, which just accepts up to maxConnections connections. Those connections that are beyond the limit remain in the operating system's queue (the acceptCount attribute is a hint for the OS on the preferred size of such a queue).

However the rest of Tomcat Coyote's architecture is obviously different from that of the Oracle iPlanet Web Server and depends on the connector type used.

You can read the details of the NIO connector in this article. Basically:

  • the server reacts to network events by polling the sockets using Selectors. This way one thread can service all the client connections.

  • there are only 3 threads dealing with the network I/O:

    1. the Acceptor, which only accepts new connections and sends them to the poller,
    2. the Poller, which responds to read/write events and dispatches them to the request executor,
    3. the BlockPoller, which disappeared in version 9.0.47 and dealt with blocking operations on the ServletInputStream and ServletOutputStream. The Poller took its tasks.
  • there is no connection queue. The threads mentioned above just submit Runnable tasks to the executor. Internally the executor has a queue of Runnables and each thread picks a task from there when it is free.

Related