Recipe 21.4. Stress Testing Your Web Site21.4.1. ProblemYou want 21.4.2. SolutionUse a stress-testing and benchmarking tool to simulate a variety of load levels. 21.4.3. DiscussionStress testing is frequently confused with benchmarking, and it is important to recognize the difference between the two activities. Benchmarking a web site is often a somewhat casual activity when performed by an individual developer. The most commonly used tool is the % /usr/bin/ab -n 1000 -c 100 -k This test would return a report illustrating the average response time for requests to http://www.example.com/test.php, based on 1,000 requests, grouped in batches of 100 concurrent requests. While that sort of test has value'it gives you a reasonable estimation of how many requests you can serve per second under normal load'it doesn't tell you much about how your entire web application will behave under heavy load. It only pounds on one URL at a time, after all. Stress testing is a testing technique whose intent is to break your web application. By testing to a breaking point, you can identify and repair weaknesses in your application, or gain a better understanding of when you will need to add additional hardware. When combined with code profiling, you can also get an idea of what part of your application will need to scale first; i.e., will you need to add more servers to your database cluster before you need to add more frontend web server machines? An excellent open source tool for stress testing is Siege. Siege can be configured to read a large number of URLs from a configuration file and run through them in order (regression testing), or it can read a list or URLs and hit them randomly, which better approximates real-world usage of a web site. Siege can also pound on a single URL in a similar fashion to ab. If you are unable to install Siege on your system, Lincoln Stein's torture.pl script is a good alternative. Many of Siege's design concepts were inspired by torture.pl, and the two tools produce similar reports. 21.4.4. See AlsoSource and documentation for Siege at http://www.joedog.org/JoeDog/Siege; ab at http://httpd.apache.org/docs/2.0/programs/ab.html; source and documentation for torture.pl at http://stein.cshl.org/~lstein/torture/. |
Monday, January 11, 2010
Recipe 21.4. Stress Testing Your Web Site
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment