Apache Tuning Part 2

December 30th, 2008 Category: Apache

Let’s assume your web server has high disc IO. Every access to a .PHP, .HTML, .JPG, .GIF, etc wil cause a log entry which will be stored on hard disc. In such a case it helps to disable all apache loggings.

You can check the opened log file from apache using the command:

lsof |grep apache|grep log

Oh yes, if you serve lot’s of domains on your server this list will be quite long. To disable logging just uncomment the corresponding lines e.g. in your virtual host definition:

#ErrorLog /var/log/apachd2/mydonain.de-error_log
#CustomLog /var/log/apache2/mydomain.de-access_log combined

Afterwards check your apace configuration for errors:

apache2ctl -t

In case of syntax OK just restart your apache server:

apache2ctl -k graceful

This command is qute because it does a “graceful” restart without anoying users accesing your server right now.

Hint

How to check if my disc IO is high?

Use the command “vmstat 1″ and check the section “IO” (what else…). You will see bi and bo which means blocks received and blocks sent. In case the numbers are high, you will have high disc IO.

procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
0  0 659476  41604   8732 347304    3    3    37    41   20   14 19  7 58 16
3  0 659476  41604   8732 347336    0    0     0     0  410  314  7  0 93  0
0  0 659476  41464   8740 347328    0    0     0   424  522  321 11  1 86  2

Apache Tuning Part 1

December 30th, 2008 Category: Apache

This article applies to apache version 2.2.3 also it will work for other versions.

Apache needs a lot of memory, this will decrease performance on a machine with e.g. 1 GByte memory and about 60 users accessing the server simultaneously a lot. There is a simply method to save memory: disable all unused modules. Yes, it really helps!

Why does it help? Because every apache process started – and a lot will be started when several users are accessing the server – will load all enabled modules.

To get an overview how much memory is consumed by the modules use the command

lsof | grep apache | grep modules

Using this command you will also see which modules consumes much memory.

In my case only the following modules are used:

  • actions.load
  • authz_default.load
  • authn_file.load
  • auth_basic.load
  • authz_user.load
  • env.load
  • mime.load
  • rewrite.load
  • userdir.load
  • alias.load
  • authz_host.load
  • deflate.load
  • expires.load
  • negotiation.load
  • setenvif.load
  • headers.load
  • speling.load
  • cgi.load
  • dir.load
  • include.load
  • php5.load

Modules which are not needed are disabled using the command

a2dismod <module_name>