2
  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

vuhoanghiep1993
  • 715
  • 1
  • 8
  • 15
  • Does this answer your question? [Tomcat - maxThreads vs maxConnections](https://stackoverflow.com/questions/24678661/tomcat-maxthreads-vs-maxconnections) – Piotr P. Karwasz Jul 05 '21 at 07:27
  • I suppose you are aware that Oracle iPlanet Web Server and Tomcat are two different products. Tomcat Coyote has always an acceptor thread and a request processing thread pool, but the details of the interactions between those two depend on the endpoint type (BIO (removed in 8.5), NIO, NIO2 or APR). Can you clarify which endpoint type are you interested in? – Piotr P. Karwasz Jul 05 '21 at 07:40
  • 1
    @PiotrP.Karwasz This is my mistake, I mean tomcat coyote nio , can you explain what happen when a request to tomcat server run a spring boot app, thank you – vuhoanghiep1993 Jul 06 '21 at 07:24

1 Answers1

2

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.

Piotr P. Karwasz
  • 12,857
  • 3
  • 20
  • 43