Search This Blog

Wednesday, February 16, 2011

Tuning Apache and PHP for Speed on Unix


Here is my compilation of tips on how to optimise Apache on Linux for PHP and CGI programs. These tips can also apply to Perl and Python. Links will open in a new window.
Also read my essay Optimizing PHP for a more in depth coverage of these issues with case studies.
To tune well, you need to benchmark your Web server. You can get some benchmark figures usingApacheBench (ab) or httperf. If you are an OS agnostic like me, I recommend using Microsoft's excellent free Web Application Stress Tool (WAST - requires M'soft Windows). WAST is more flexible than ab because it allows you to define different GET parameters for each thread. This is important because it allows you to simulate multiple PHP sessions via the PHPSESSID GET parameter. Avoid benchmarks involving PHP sessions when using ab as the sessions will become an artificial bottleneck. More info on using WAST with PHP.
To monitor the Apache server, I use the command top d 1 which displays CPU and memory usage of all processes on the machine, and apachectl status.

No comments:

Post a Comment