Improving Apache performance by cleaning up its configuration
Posted in apache, guide, tunning on February 16th, 2010 by fseek – 3 CommentsSimple steps to improve Apache performance by cleaning up unused modules.
Apache is the most used web server on Linux systems and it has lots of features. By default, it generally comes with many of these features enabled, but if you don’t need them, why waste memory, cpu and at the end performance?
Let’s tune it a bit!
Default Apache
With the default Apache installation (on CentOS), it generally uses this ammount of memory:
# top |grep httpd
apache 3682 0.0 6.7 37408 24836 ? S Feb13 1:30 /usr/sbin/httpd
So around 37m for the worker processes. I also did a simple test with “ab” (Apache benchmark) to see how many requests per second it can take:
# ab -n 500 http://fseek.me/
..
Requests per second: 2.31 [#/sec] (mean)
..
So about 2.32 requests per second (I re-did this time a few times to get an average).
Cleaning up the configuration
I went to the Apache configuration (/etc/httpd/conf/httpd.conf) and disabled the modules that I was sure I wouldn’t use:
#LoadModule authn_dbm_module modules/mod_authn_dbm.so
#LoadModule ldap_module modules/mod_ldap.so
#LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
#LoadModule dav_module modules/mod_dav.so
#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule speling_module modules/mod_speling.so
#LoadModule userdir_module modules/mod_userdir.so
#LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
#LoadModule proxy_http_module modules/mod_proxy_http.so
#LoadModule proxy_connect_module modules/mod_proxy_connect.so
#LoadModule cgi_module modules/mod_cgi.so
So I commented the proxy modules, cgi, ldap, etc.
Apache after the cleanup
After the cleanup (and restarting Apache), lets see how much memory it is using:
# top |grep httpd
apache 15715 0.8 4.4 29900 16588 ? S 15:24 0:00 /usr/sbin/httpd
So it went down from 37m to 29m of memory usage. If you are in a VPS (or slow box), that can really help performance. So, in addition to the memory usage reduction, let’s see if it improved the performance for our end users (average number of requests per second)
# ab -n 500 http://fseek.me/
..
Requests per second: 2.93 [#/sec] (mean)
..
That’s a good improvement too! From 2.32 requests per second, we increased to almost 3 per second (using ab, non-concurrent). The average time to complete the request also dropped from 429ms to 410ms…
It may look not much, but for such a simple change, why not do it?
