6

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.

4

1 回答 1

11

写下简单的 PHP 脚本:

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

然后编写一个 bash 脚本,该脚本将多次运行此 PHP 脚本,您将看到...

如果您想使用 DB 对服务器进行压力测试,请执行类似的操作:

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

并再次从 bash 运行它几次......

于 2012-05-11T10:07:16.247 回答