If you want to benchmark changes that you are making to verify that
they are in fact making a difference in performance, use ab (Apache bench), which
you will find in the bin
directory of your Apache installation:
ab -n 1000 -c 10 http://www.example.com/test.html
Apache bench is a command-line utility that comes with Apache and lets you do very basic performance testing of your server. It is especially useful for making small changes to your configuration and testing server performance before and after the change.
The arguments given in the previous example tell ab to request the resource
http://www.example.com/test.html 1000 times
(-n 1000 indicates the number of requests) and to
make these requests 10 at a time (-c 10 indicates the
concurrency level).
Other arguments that may be specified can be seen by running
ab with the -h
flag. Of particular interest is the -k flag, which
enables keepalive mode. See the following keepalive recipe for additional details
on this matter.
There are a few things to note about ab when using it to evaluate performance.
Apache bench does not mimic Web site usage by real people. It
requests the same resource
repeatedly to test the performance of that one thing. For example, you
may use ab to test the performance
of a particular CGI program, before and after a performance-related
change was made to it. Or you may use it to measure the impact of
turning on .htaccess files, or
content negotiation, for a particular directory. Real users, of
course, do not repeatedly load the same page, and so performance
measurements made using ab may not
reflect actual real-world performance of your Web site.
You should probably not run the Web server and ab on the same machine, as this will introduce more uncertainty into the measurement. With both ab and the Web server itself consuming system resources, you will receive significantly slower performance than if you were to run ab on some other machine, accessing the server over the network. However, also be aware that running ab on another machine will introduce network latency, which is not present when running it on the same machine as the server.
Finally, there are many factors that can affect performance of the server, so you will not get the same numbers each time you run the test. Network conditions, other processes running on the client or server machine, and a variety of other things may influence your results slightly one way or another. The best way to reduce the impact of environmental changes is to run a large number of tests and average your results. Also, make sure that you change as few things as possible—ideally, just one—between tests, so that you can be more sure what change has made any differences you can see.
Finally, you need to understand that, while ab gives you a good idea of whether certain changes have improved performance, it does not give a good simulation of actual users. Actual users don’t simply fetch the same resource repeatedly; they obtain a variety of different resources from various places on your site. Thus, actual site usage conditions may produce different performance issues than those revealed by ab.
The new edition of the Apache Cookbook offers you updated solutions to the problems you're likely to encounter with Apache. Thoroughly updated for Apache versions 2.0 and 2.2, this book includes more than 200 recipes ranging from simple tasks, such installing the server on Red Hat Linux or Windows, to more complex tasks, such as setting up name-based virtual hosts or securing and managing your proxy server.




Help






