Peter Roßbach, core developer at the Tomcat project, held a talk at RheinJUG in Düsseldorf on Thursday. It was very delightful mixture on Tomcat architecture, best practices, Open Source community as well as current and future developments, rather than a dry technical talk.
Tuning Tomcat Performance
Regarding performance, he mentioned that the main negative factor is to use development mode for production environments. Well have a look at a few parameters and which do affect Tomcat performance.
As of tomcat 6 there is the improved protocol handler available:
<Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
additionally Java NIO powers a new improved file download option. Servlets just have to set sendfile request parameters and not output any more data. That file will then be pushed by tomcat to the user:
org.apache.tomcat.sendfile.filename: Canonical filename of the file which will be sent as a String
org.apache.tomcat.sendfile.start: Start offset as a Long
org.apache.tomcat.sendfile.end: End offset as a Long
production servers should not deploy automatically:
<Host name="localhost" autoDeploy="false" deployOnStartup="false" deployXML="false">
The Jasper JSP compiler should be tuned as well:
Using mod_jk for loadbalancing
As a second main topic of his talk, he presented the module “mod_jk”, which in connection with a Apache Httpd and the Tomcat AJP protocol enables distributing java applications on multiple Tomcat servers.
He explained the different loadbalancing setups and that it might make even sense to user a Tomcat server per application, as this allows better memory management and improves overall high-availibility.
<Connector port="8009" protocol="AJP/1.3"/>
<Engine name="Catalina" defaultHost="localhost" jvmRoute="node01">
mod_jk Configuration inside Httpd:
LoadModule jk_module "modules/mod_jk.so"
JKMount /myapps* loadbalancer
Further documentation on mod_jk worker can be found here:
In total a very interesting talk, with lots of stuff to learn from, let it be the Tomcat project or the Tomcat architecture, or how Open Source “lives” and what one as developer or architect should consider when developing a Java web application.