Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stress test server memory and processor?

At work we are in the middle of a server migration and we want to stress test the new server before starting to migrate our data.

I was wondering if anyone had any ideas for scripts that will put intense load on the processor and/or memory?

It is a linux server running on Red Hat 5 OS and Apache 2.2.1.

It doesn't have to push it to it's physical limits, it's just to use as a benchmark to compare to our old server so we can see how much of an improvement the new setup is over the current/old configuration.

Ideally it would be a shell or php script since php is what will be installed and what we develop in.

like image 652
martincarlin87 Avatar asked May 11 '12 08:05

martincarlin87


1 Answers

Write down simple PHP script:

<?php
for($i = 0; $i < 1000000000; $i++) {
     $a += $i;
}

Then write a bash script that will run this PHP script for several times and You will see...

If You want to stress test the server with DB, do a similar one:

for($i = 0; $i < 9999; $i++) {
    $conn = mysql_connect(...);
    $db = mysql_select_db(...);
    $res = mysql_query(...);
    $data = mysql_fetch_assoc($res);
    mysql_close();
}

And again run it from bash for several times...

like image 73
shadyyx Avatar answered Nov 11 '22 01:11

shadyyx