PHP Performance Tuning Stress-Testing Your Website - Supercoders | Web Development and Design | Tutorial for Java, PHP, HTML, Javascript PHP Performance Tuning Stress-Testing Your Website - Supercoders | Web Development and Design | Tutorial for Java, PHP, HTML, Javascript

Breaking

Post Top Ad

Post Top Ad

Sunday, July 7, 2019

PHP Performance Tuning Stress-Testing Your Website

PHP Performance Tuning


Stress-Testing Your Website

Problem

You want to find out how well your website performs under a heavy load.

Solution

Use a stress-testing and benchmarking tool to simulate a variety of load levels.

Discussion

Stress testing is frequently confused with benchmarking, and it is important to recognize the difference between the two activities.

Benchmarking a website is often a somewhat casual activity when performed by an individual developer. The most commonly used tool is the Apache HTTP server benchmarking tool, ab, which is designed to test how many requests per second an HTTP server is capable of serving. For example:

       % /usr/bin/ab -n 1000 -c 100 -k www.example.com/test.php

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.

Though 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 of URLs and hit them randomly, which better approximates real-world usage of a website. 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.

No comments:

Post a Comment

Post Top Ad