Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Dec 2006
    Posts
    417
    Thanks
    168
    Thanked 1 Time in 1 Post

    Stress Testing a Website -- PHP Script

    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?

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    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.

  • #3
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    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.
    My thoughts on some things: http://codemeetsmusic.com
    And my scrapbook of cool things: http://gjones.tumblr.com


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •