<p>We are currently using Apache 2.2.3 and Tomcat 5 (Embedded in JBoss 4.2.2) using <code>mod_proxy_jk</code> as the connector.</p>

<p>Can someone shed some light on the the correct way to calculate / configure the values below (as well as anything else that may be relevant).  Both Apache and Tomcat are running on separate machines and have copious amounts of ram (4gb each).</p>

<p>Relevant server.xml portions:</p>

<pre><code>&lt;Connector port="8009"
    address="${jboss.bind.address}"
    protocol="AJP/1.3"
    emptySessionPath="true"
    enableLookups="false"
    redirectPort="8443"
    maxThreads="320"
    connectionTimeout="45000"
/&gt;
</code></pre>

<p>Relevant httpd.conf portions: </p>

<pre><code>&lt;IfModule prefork.c&gt;
  StartServers       8
  MinSpareServers    5
  MaxSpareServers   20
  ServerLimit      256
  MaxClients       256
  MaxRequestsPerChild  0
&lt;/IfModule&gt;
</code></pre>

MaxClients
This is the fundamental cap of parallel client connections your apache should handle at once.
With prefork, only one request can be handled per process. Therefore the whole apache can process
at most
$MaxClients requests in the time it takes to handle a
single
request. Of course, this ideal maximum can only be reached if the application needs less than 1/$MaxClients resources per request.
If, for example, the application takes a second of cpu-time to answer a single request, setting MaxClients to four will limit your throughput to four requests per second: Each request uses up an apache connection and apache will only handle four at a time. But if the server has only two CPUs, not even this can be reached, because every wall-clock second only has two cpu seconds, but the requests would need four cpu seconds.
MinSpareServers
This tells apache how many idle processes should hang around. The bigger this number the more burst load apache can swallow before needing to spawn extra processes, which is expensive and thus slows down the current request.
The correct setting of this depends on your workload. If you have pages with many sub-requests (pictures, iframes, javascript, css) then hitting a single page might use up many more processes for a short time.
MaxSpareServers
Having too many unused apache processes hanging around just wastes memory, thus apache uses the MaxSpareServers number to limit the amount of spare processes it is holding in reserve for bursts of requests.
MaxRequestsPerChild
This limits the number of requests a single process will handle throughout its lifetime. If you are very concerned about stability, you should put an actual limit here to continually recycle the apache processes to prevent resource leaks from affecting the system.
StartServers
This is just the amount of processes apache starts by default. Set this to the usual amount of running apache processes to reduce warm-up time of your system. Even if you ignore this setting, apache will use the Min-/MaxSpareServers values to spawn new processes as required.
More information
See also
the documentation for apache's multi-processing modules
.