Tip

Tomcat performance optimization through consolidated log file handlers

By default Tomcat uses several log file handlers, but performance can easily be optimized by configuring the server to use only one.

Whether you are a software developer tasked with troubleshooting a live application or a systems administrator performing strident monitoring of your production server, regularly checking the various application and server logs that your infrastructure generates is a critical activity.

Any time an application is monitored, the monitoring itself degrades the performance.

Lukas Stewart

Of course, anyone who has taken even an introductory performance tuning course knows that the Heisenberg uncertainty principle applies just as much to application monitoring as it does to quantum mechanics. That is, any time an application is monitored, the monitoring itself degrades the performance.

Fortunately, in modern computing environments, the task of generating text and writing it to an output stream is a fairly mundane task that doesn't overburden a multi-processor machine with peta-bytes of memory, something that couldn't be said for servers of the past where every moment spent logging robbed running applications of precious clock-cycles and computing power.

But regardless of the power of modern server hardware, a prudent administrator knows that there is never any excuse for wasting resources, and any optimization that improves performance without introducing any peripheral problems is a good one, which is why anyone running a Tomcat server should be interested in eliminating the needless duplication of log file handlers.

Consolidating log file handlers

By default, Tomcat uses two handlers for generating log files. However, this can be changed by opening up the logging.properties file and looking for the following entry:

.handlers = 1catalina.org.apache.juli.FileHandler, 
                   java.util.logging.ConsoleHandler

By simply changing the .handlers entry to use the FileHandler and the FileHandler only, you can consolidate multiple handlers into one and reduce the overhead in writing applications logs:

.handler = 1catalina.org.apache.juli.FileHandler

It is just a simple change, but by consolidating the log file handlers, you reduce the overhead of logging, which minimizes the impact of performance monitoring and subsequently releases otherwise consumed resource to handle the real application load.

Do you have any good tips that will help administrators save time when configuring and optimizing the Tomcat application server? Let us know about your favorite tips and tricks.

Recommended Titles:

Tomcat: The Definitive Guide by Jason Brittain
Apache Tomcat 7 Essentials by Tanuj Khare
Java Performance by Charlie Hunt
Java Performance Tuning (2nd Edition) by Jack Shiraz
Java Performance and Scalability by Henry H. Liu
 

Dig Deeper on Front-end, back-end and middle-tier frameworks

App Architecture
Software Quality
Cloud Computing
Security
SearchAWS
Close