Using single thread model servlets – Oracle Audio Technologies A86828-01 User Manual

Page 61

background image

Optimizing Servlet Performance

Optimizing Apache JServ



If the request is not part of a session, mod_jserv selects an engine based on
the process ID of the httpd process and the number of entries in the list of
available JServs, as follows:

JServ_id to handle the request = httpd_pid % number of JServs in the list

This method distributes requests across the available JServ engines fairly

Using Single Thread Model Servlets

Oracle recommends that you write your servlets to implement the
SingleThreadModel (STM) interface. An application that was modified to
implement the STM interface demonstrated a 25% improvement in response time,
probably due to a decrease in synchronization bottlenecks.

It is also much easier to manage database connections with STM servlets. The
database connection can be set up in the


method of the servlet, and closed

in the


method. When executing the servlet’s




method, you need not be concerned with obtaining a database connection.
Alternatively, you can use JDBC connection caching.

There are three parameters in the file that impact the performance
of STM servlets in particular. These govern:

The minimum number of servlet object instances that will be generated and
available after the servlet class is loaded

The maximum number that can be generated

The number that should be generated if the available instances are insufficient

Because it is very costly to generate instances while the system is running, Oracle
recommends that you set your minimum to equal your maximum value. The
optimum value depends somewhat on how many connections your database server
can handle. This should be split among the JServ processes, as follows:


Chapter 3, "Sizing and Configuration"

for suggestions on determining the right

number of JServ processes for your application, and

"Load Balancing"

on page 5-4

for the steps to configure them. Suppose you’ve determined that you want 10
servlet instances per process. Then, in the properties file for your zone, set:

Total DB connections / Number of JServ processes = Number of STM servlet

instances per process