How does Tomcat distribute servlet/JSP processing to the 20+ Java processes it creates?
Theoretically yes, Tomcat will try to optimize the requests to handle as much simultaneous requests it can.
[N.B.: Under Linux, each Java Thread appears in the process list (ps) as a separate process. This is because native Linux threads are implemented as lightweight processes. However, there is still only one Java process space -- the memory/CPU reported by each thread is actually shared among all threads. -A]
[...] the (default) pool behaviour instructed by it is:
Upper bound for concurrency of 50 threads.
When the pool has more then 25 threads standing idle it will start to kill them.
The pool will start 10 threads on creation, and it will try to keep 10 vacant threads (as long as the upper bound is kept).
The default configuration is suitable for medium load sites with an average of 10-40 concurrent requests. If your site differs you should modify this configuration (for example reduce the upper limit). Configuring the pool can be done through the <Connector> element in server.xml as demonstrated in the next fragment:<Connector className="org.apache.tomcat.service.PoolTcpConnector"> <Parameter name="handler" value="org.apache.tomcat.service.connector.Ajp12ConnectionHandler"/> <Parameter name="port" value="8007"/> <Parameter name="max_threads" value="30"/> <Parameter name="max_spare_threads" value="20"/> <Parameter name="min_spare_threads" value="5" /> </Connector>As can be seen the pool has 3 configuration parameters:
max_threads - defines the upper bound to the for the concurrency, the pool will not create more then this number of threads.
max_spare_threads - defines the maximum number of threads that the pool will keep idle. If the number of idle threads passes the value of max_spare_threads the pool will kill these threads.
min_spare_threads - the pool will try to make sure that at any time there is at least this number of idle threads waiting for new requests to arrive. min_spare_threads must be bigger then 0.
You should use the above parameters to adjust the pool behavior to your needs.[...]