How to stress test server memory and processor?

梦想与她 提交于 2021-02-19 00:48:02

问题


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.


回答1:


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...



来源:https://stackoverflow.com/questions/10548400/how-to-stress-test-server-memory-and-processor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!