April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Categories

April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Tuning Apache + Tomcat

ATG: Tuning Apache + Tomcat

I did some tuning on Apache which vastly decreased response times.

The tests show increase vast decrease in response. (see table below) which is due to the following improvements made effective by the tuning (Increased maxclients, KeepAlive on. KeepAliveTimeout etc):

1) Reusable connections to handle multiple requests from the same client, which in return causes less connections from client to the web-server and decreases response times.

2) Because of Point 1, apache now needs less Httpd clients to server more load, hence decrease in resource usage (Memory).

4) MaxClients has been increased to 1000, hence if required apache can now expand to serve more load without the queue buildup which causes high latencies.

Request 100 100 (Tuned) Perf gain (%) 400 400(Tuned) Perf gain (%)
1-homePage 850.21 253.52 70.18 4812.72 533.55 88.91
2-login 1132.27 593.72 47.56 5411.01 1186.64 78.07
3-1-search 1698.79 1616.14 4.87 4303.77 4366.99 -1.47
3-2-searchPagination 1822.23 1005.70 44.81 8810.29 3429.22 61.08
4-productDetails 1043.62 398.56 61.81 5454.44 686.17 87.42
5-cartOverviewDeleteAllProducts 328.95 320.88 2.45 712.25 514.25 27.80
5-cartOverviewViaMiniCart 1026.01 421.22 58.95 5248.49 743.63 85.83
6-cartOverviewAddProduct 351.52 336.90 4.16 873.58 824.36 5.63
7-cartPreview 1352.69 665.76 50.78 6218.38 1162.07 81.31
8-cartConfirm 908.65 848.04 6.67 1662.67 1251.99 24.70
9-logout 840.03 214.11 74.51 5095.36 523.79 89.72

The changes will require the following changes in the HTTP.cong (/etc/httpd/conf/httpd.conf)

—-
KeepAlive on
MaxKeepAliveRequests 100
KeepAliveTimeout 2

<IfModule prefork.c>
StartServers 10
MinSpareServers 10
MaxSpareServers 20
ServerLimit 1000
MaxClients 1000
MaxRequestsPerChild 4000
</IfModule>

<IfModule worker.c>
StartServers 10
MaxClients 1000
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 1000
</IfModule>

Reference: http://blog.springsource.org/2008/10/14/optimising-and-tuning-apache-tomcat-part-2/

Note: the above improves performance but exausts mod_jk thread pools, as the response are shorter now, hence more load.

Read the following on MPMs to fine tune it further:

Choosing an MPM

Apache 2.x supports pluggable concurrency models, called Multi-Processing Modules (MPMs). When building Apache, you must choose an MPM to use. There are platform-specific MPMs for some platforms: beosmpm_netwarempmt_os2, and mpm_winnt. For general Unix-type systems, there are several MPMs from which to choose. The choice of MPM can affect the speed and scalability of the httpd:

  • The worker MPM uses multiple child processes with many threads each. Each thread handles one connection at a time. Worker generally is a good choice for high-traffic servers because it has a smaller memory footprint than the prefork MPM.
  • The prefork MPM uses multiple child processes with one thread each. Each process handles one connection at a time. On many systems, prefork is comparable in speed to worker, but it uses more memory. Prefork’s threadless design has advantages over worker in some situations: it can be used with non-thread-safe third-party modules, and it is easier to debug on platforms with poor thread debugging support.

For more information on these and other MPMs, please see the MPM documentation.

http://httpd.apache.org/docs/2.2/misc/perf-tuning.html

http://tomcat.apache.org/connectors-doc/reference/workers.html

https://community.jboss.org/wiki/OptimalModjk12Configuration

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>