Benchmarking Tomcat Performance - Building the APR Connector (
Page 4 of 4 )
We built the APR connector like this:
# CFLAGS="-O3 -falign-functions=0 -march=athlon64 -mfpmath=sse -mmmx -msse -msse2 -
msse3 -m3dnow -mtune=athlon64" ./configure --with-apr=/usr/bin/apr-1-config --
prefix=/opt/tomcat/apr-connector
# make && make install
We used the same
CFLAGS
when building Apache httpd
and mod_jk
. Here’s how we built and installed mod_jk
:
# cd tomcat-connectors-1.2.20-src/native
# CFLAGS="-O3 -falign-functions=0 -march=athlon64 -mfpmath=sse -mmmx -msse -msse2 -
msse3 -m3dnow -mtune=athlon64" ./configure --with-apxs=/opt/httpd/bin/apxs
[lots of configuration output removed]
# make && make install
This assumes that the root directory of the Apache httpd
we built is /opt/httpd
.
We built the APR connector, httpd
, and mod_jk
with GCC 4.1.1:
# gcc --version
gcc (GCC) 4.1.1 20061011 (Red Hat 4.1.1-30)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
We downloaded Apache httpd
version 2.2.3 from http://httpd.apache.org
and built it two different ways and benchmarked each of the resulting binaries. We built it for prefork MPM and worker MPM. These are different multithreading and multiprocess models that the server can use. Here are the settings we used for prefork and worker MPM:
# prefork MPM
<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000
</IfModule>
# worker MPM
<IfModule worker.c>
StartServers 3
MaxClients 192
MinSpareThreads 1
MaxSpareThreads 64
ThreadsPerChild 64
MaxRequestsPerChild 0
</IfModule>
We disabled Apache httpd
’s common access log so that it would not need to log any
thing per each request (just as we configured Tomcat). And, we turned on Apache httpd
’s
KeepAlive
configuration option:
KeepAlive O
n
MaxKeepAliveRequests 100
KeepAliveTimeout 5
We enabled mod_proxy
one of two ways at a time. First, for proxying via HTTP:
|
ProxyPass /tc http://127.0.0.1:8080/ |
|
ProxyPassReverse /tc http://127.0.0.1:8080/ |
Or, for proxying via AJP:
ProxyPass /tc ajp://127.0.0.1:8009/
ProxyPassReverse /tc ajp://127.0.0.1:8009/
And, we configured mod_jk
by adding this to httpd.conf
:
|
LoadModule jk_module /opt/httpd/modules/mod_jk.so |
|
JkWorkersFile /opt/httpd/conf/workers.properties |
|
JkLogFile /opt/httpd/logs/mod_jk.log |
|
JkLogLevel info |
|
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] " |
|
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories |
|
JkRequestLogFormat "%w %V %T" |
|
JkMount /tc/* worker1 |
Plus we created a workers.properties
file for mod_jk
at the path we specified in the httpd.conf
file:
worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.connection_pool_size=150
worker.worker1.connection_pool_timeout=600
worker.worker1.socket_keepalive=1
Of course, we enabled only one Apache httpd
connector module at a time in the configuration.
Please check back next week for the continuation of this article.