Optimizing Servlet Performanc e
Optimizing Apache JServ 5-3
Optimizing Servlet PerformanceThis section discusses strategies for optimizing JServ performance: loading servlets
when starting the JVM, and load balancing.
The terms “repository” and “zone” are used in this discussion. Servlets,
repositories, and zones are analogous to files, directories and virtual hosts. A servlet
is a single unit, a repository is a collection of servlets, and a zone is a collection of
repositories.
Loading Servlet Classes
Apache JServ allows you to load servlet classes when the JVM is started. To do this,
put the servlets to load in the servlets.startup directive in the servlet zone
properties file. When the servlet is loaded, its init()method is called. All other
servlets (those not listed in servlets.startup) are loaded and initialized on first
request.
Using this facility increases the start-up time for your JServ process, but improves
first-request latency for servlets.
Pre-Loading with JSPs
If you are using a JSP as the servlet (your code does not extend HttpServlet), you
will be unable to use this pre-load option, but you could pre-load the JSP runner by
including the oracle.jsp.jspServlet in servlets.startup.
If the first-request latency for your initialization routines is really a performance
issue, you can achieve some of the results described above by creating a dummy
servlet to call your one-time initialization routines in its init() method. You must
add the name of the dummy servlet to servlets.startup.
Automatic Class Reloading
If autoreload.classes is set to true for a zone (the default), then each time one
of that zone’s servlets is requested, every class that has been loaded from a
repository in that zone is checked to see if it has been modified. If one of the classes
has changed, then all previously loaded classes from the zone’s repositories are
unloaded, which means that as the classes are needed, they will be loaded from
their class files again.
This is a useful development feature, because you can install new versions or drop
in new class files without restarting the server. For optimal performance in
production environments, however, you should set both automatic class reloading