Main Content

Apache Tomcat Performance Tuning

Archive - Originally posted on "The Horse's Mouth" - 2007-09-29 05:24:52 - Graham Ellis

Have you noticed what a lack of information there is in the printed material (or on the web too, come to that!) on performance tuning Apache Tomcat? The subject came up briefly during the course that I completed yesterday, when we looked at the changing the heap sizes and number of threads, and selecting either the client or server JVM. Really it's one of those areas where I can't give you hard and fast rules for these parameters, and sometimes an apparantly contradictory setting will work wonders. For example, reducing the number of threads may increase performance as Tomcat concentrates on giving fast and furious service to a few customers at a time, rather that having hordes of them in the pipeline at the same time.

"Increase your cpu power, increase the memory" one of the books told us - and with the modern low price of hardware, that could be exactly the right message for some people. So could "increase the bandwidth to the cpu" sometimes. But in each case, do check that you're pushing on the right bound. Looking at yesterday's case, the cpu was running at 100% and there was free memory available - so an extra few Gbytes would have sat idle; a move powerful cpu would have helped, as might pulling other tasks off the same cpu.

"Should I run multiple instances of Tomcat"? Maybe; on a single processor machine, it's going to be questionable whether you'll gain much. With multiple processors and one instance per processor, or with multiple hosts, then major throughput advances can be made. But once you have multiple instances of Tomcat running, you've got two extra complexites - how to share the load, and ensuring that the Tomcats stay syncronised in an appropriate way.

There's some general load balancing and clustering information and some more specific Apache load sharing information available via links. And whilst we don't run public Apache Tomcat tuning course, we have been known to cluster machines together, play with the settings, and bombard them with traffic to help a small group from a individual client understand the metrics of some of the factors I have mentioned. See here for commercial details.