PHP Form stress testing

I’m going to be launching my site in around 3 weeks and think that now is the time to do some testing. What i’d like to make is a script that submits data to my database (like the form would) and do it at a set interval, so like every 5 seconds hit the database for an INSERT.

The data being entered doesn’t matter. I just want to see how well my management system copes if users are hitting the site and filling in their requests…

Seeing as this is beyond me at the moment, could one of you guys give me some pointers…

I’m guessing i just need some variables set up for the actual data being submitted, the sql query and some sort of loop to run the sql query.

Thanks,
Andrew

Below is what I would do if I wanted to achive what you are trying to. You will obviously need to change a few things, but should get what you need. At least put on the right track.

[php]<?php
$runs = 35; //How many times you want to run the insert statement.
$sleep = 5; //How long you want in between inserts.

for($i = 0; $i <= $runs; $i++)
{
sleep($sleep);

$q = "INSERT INTO mytable (field1, field2, field3) VALUES ('value1', 'value2', 'value3')";
mysql_query($q) or die("Error inserting. Reason: " . mysql_error());

}?>[/php]

That is spot on. Thanks very much for your help Ragster. I’m going to have to start paying you i reckon! :-P

You probably caught it, but my for loop was wrong… I had $i = $runs which is wrong should be $i <= $runs or some other condition, but the way I had it was wrong.

I made the edit and corrected it.

Sponsor our Newsletter | Privacy Policy | Terms of Service