Apache + Tomcat with mod_jk: setting maxThread in load balancing

I have an Apache + Tomcat installation with mod_jk on 2 servers. Each server has its own Apache + Tomcat pair, and each request is served by Tomcat load balancers on two servers.

I have a question about how Apache maxClient and Tomcat maxThread should be installed.

Default numbers, Apache: maxClient=150, Tomcat: maxThread=200

In this configuration, if we have only 1 server setup, it will work fine, because a Tomcat employee never receives incoming connections more than 150 at a time. However, if we balance the load between the two servers, is it possible for a Tomcat worker to get 150 + (some number from another server) and do a maxThread overflow like SEVERE: All threads (200) are currently busy ?

If so, should I set Tomcat maxThread=300 in this case?

thanks

+6
multithreading tomcat apache mod-jk load-balancing
source share
1 answer

Setting maxThreads up to 300 should be fine - there are no fixed rules. It depends on whether you see any connections failing.

Increasing too many causes high memory consumption, but Tomcats production is known to work with 750 threads. See here also. http://java-monitor.com/forum/showthread.php?t=235

Are you sure you got the SEVERE error? I tested our Tomcat 6.0.20 and it forwards the INFO message when crossing maxThreads.

 INFO: Maximum number of threads (200) created for connector with address null and port 8080 

It does not refuse connections until the acceptCount value is crossed. The default value is 100.

From Tomcat docs http://tomcat.apache.org/tomcat-5.5-doc/config/http.html

The maximum queue length for incoming connection requests when everything is possible using request processing threads. Any requests received in the queue will be completely denied. The default value is 100.

How it works,

1) As the number of simultaneous requests increases, threads will be created up to the configured maximum (value of the maxThreads attribute).

So, in your case, at this moment the message "Maximum number of threads created (200)" will appear. However, requests will still be queued for service.

2) If more concurrent requests are received, they are queued up to the configured maximum (value of the acceptCount attribute).

Thus, 300 requests can be accepted without fail. (assuming your acceptCount defaults to 100)

3) Crossing this number causes Connection Refused errors until resources are available for processing them.

So you should be fine until you click on step 3

+7
source share

All Articles