Getting Maximum Programming Performance from Apache Tomcat 5.5.1
Tomcat 5.5.1 now includes the majority of changes to its CATALINA release, which translates into dozens of new and revised module options and selections that are too numerous to list here. (See the changelog for what's new.)
To get greater performance from Tomcat, consider the tips in the following sections.
Disable Modules That You Don't Need
Several modules are enabled by default when Tomcat 5.5.1 is first installed. Before getting started with the server, disable all modules that aren't needed. Unneeded modules drag down performance and waste processor time, bottlenecking recompile times significantly. Many third-party modules—PHP and mod_perl, for example—are dynamically loaded by default. Be sure to disable these modules for better system performance.
True, you need these modules to create web services applications, but selectively turning them on and off through the configure script is straightforward. (You can also use the configure –help command to find out all the specifics.)
Code in Static Mode
Consider coding in static mode instead of dynamic mode. While many Tomcat developers love the instant feedback of building applications on the fly, this technique slows programming time significantly for large Java apps. In this specific release of Tomcat 5.5.1, dynamic modules are loaded every time an application is run. To build in static mode, use the --enable-write command in the configure script. Stay away from the --enable-rewrite-shared command; it adds significant overhead to recompiling code..
Trim the Configuration File
Removing (or at least remarking out) comments in the Tomcat 5.5.1 configuration file doesn't increase performance, but makes system-level configuration changes easier to implement. You can go so far as to remove all those components of the configuration file that aren't applicable to your hardware configuration and programming environment. Making the configuration file more easily customizable will save time in having to drill through manuals for options in the future.
Get Rid of Unused System-Level Components
Several system-level components that bog down system performance can be removed easily. Here are a few:
- By default, Apache checks every request for the existence of a symbolic
link. In previous versions of the Apache server, the lstat() system
call for each directory completes a symbolic link to which the request relates.
You can turn off symbolic links as follows:
<Directory /> Options -FollowSymLinks </Directory>
- For better server performance, consider turning off the Server Status and Info monitoring. Use the SetHandler server-status option to remove the module.
- Place all CGI files in a single directory; then configure that directory for CGI execution. This approach cuts processing time significantly. Also consider leaving CGI Execution enabled.
Improving the Performance of Static Components
For web sites that have a mix of static and dynamic elements, consider the following steps for best performance:
- Move all static and dynamic elements to their own web servers. This setup isolates each component type for better performance.
- Use the mod_cache module to split elements between servers. Specifically, mod_disk_cache and mod_mem_cache are useful for defining disk-based and memory-based caches for static files.