...

View Full Version : Stress Testing a Website -- PHP Script



Bobafart
01-18-2008, 03:21 PM
I would like to design a script that stress tests my websites so I can see how they preform under heavy loads (ie. simulate a slashdot load).

I realize there are companies that do they but you have to pay for this.. I am sure I can do something similar in PHP.

How can this be done in PHP? Can someone give me some starting points on how to do it?

Fumigator
01-18-2008, 08:49 PM
If you want to just hit the website hard (kind of a denial of service attack but not bad enough to bring down the site), you can use fsockopen() to simply request the page, then put that in a loop.

I think a better exercise would be to use something like the Speed Report available via the Firefox plugin Web Developer (find it under "Tools"), and then trim down the bulk of the page as much as possible, so if the page is requested a lot, it's as light as possible.

GJay
01-19-2008, 03:04 AM
apache-bench (the command is 'ab') is pretty easy to use, you can give it a list of urls to hit, either randomly or in order, a concurrency level and either a number of requests or a time limit and it will hit pages for you. You can give it cookies too, so you can login to a site if you need to, it's pretty full-featured.

It gives you the average and slowest times, as well as a breakdown of what percentage of requests were served within particular times and the number of requests per second.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum