سؤال

I want to do a stress test on an Apache webserver that I have running on localhost. The test will request the webserver to execute a PHP application that I wrote. I want to see how much memory (RAM) the webserver (and/or the associated PHP process) consumes during the test. Or to see how much it consumed after the test is done.

My OS is Ubuntu 13.10.

I looked at Apache Bench, Apache JMeter, Siege and httperf. None of them seem to provide such information. At most, I can see some CPU load in httperf (which in most cases is 100 %, so not too relevant).

Is there some tool that can provide me with memory consumption information ? It doesn't have to be a webserver benchmarking tool, could also be another Linux software that runs in parallel with the benchmarking tool. I just think that manually monitoring the test via the top command is kind of innacurate/ammateurish. Thank you in advance.

هل كانت مفيدة؟

المحلول

htop may be exactly what you're looking for.

Personally, I recently discovered something called byobu - which gives you a handy readout on the bottom (which you can configure by pressing F9) --

And that has become my personal favorite for exactly what you're describing.

Although, you could also look into xdebug -- and use something like xdebug_memory_usage() -- in the php script you're testing to dump info into a log file at key points in your script

نصائح أخرى

I've put up a few PHP cronjobs, too, when I manually start the script through console I want to see debug and stuff, too.

I put in a method like this:

protected $consoleUpdate;

protected function printMemoryUsage() {
    if ((time() - $this->consoleUpdate) >= 3) {
        $this->consoleUpdate = time();
        echo "Memory: ",
             round(memory_get_usage(true) / (1024 * 1024)),
             " MB",
             "\r";
    }
}

Call this method as often as you like to print the scripts memory usage.

Notice the final \r in the console, which returns the cursor to the line beginning and overwrites the line. If you don't have any other output, this has the effect of your screen not moving, instead, it gets updated.

Things like top, htop, memstat, iotop, mysqltop. All these tools are excellent to see what is thoroughly cooking your server while you throw siege (and its friend apachebench) at it.

I use vmstat for memory, disk and CPU monitoring. Below are some measurements whilst copying files on a bottom of the heap Linux based Raspberry Pi. I first used vmstat in the 1980’s, monitoring DB activity on early Unix systems. More details in:

http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm

vmstat was either run from a separate terminal or in a combined script file.

pi@raspberrypi /mnt $ time sudo sh -c "cp -r 256k /mnt/new2 && sync"

40 samles at 1 second intervals
vmstat 1 40 > vmstatRes.txt

real    0m38.781s
user    0m0.400s
sys     0m8.400s

procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 0  0      0 304684  15208  65952    0    0     0     0 1109  319 39  2 59  0
 1  0      0 282788  15208  87308    0    0 10292     0 4018 2994  5 57  9 29
 1  1      0 256996  15208 112768    0    0 12380     0 4687 3863  3 53  0 44
 2  2      0 231452  15212 138028    0    0 12288    40 4781 4024  5 55  0 40
 0  1      0 216576  15216 152476    0    0  7004 10512 5649 3580  5 50  0 46
 2  2      0 201688  15216 167288    0    0  7144 17488 5341 3527  2 52  0 46
 1  0      0 195064  15216 173808    0    0  3192  9016 5909 3214  2 34  0 64
 3  0      0 169520  15216 199152    0    0 12304     0 4704 3914  2 60  0 38
 2  3      0 149988  15220 218288    0    0  9252  9892 5003 3614  2 52  0 45
 0  2      0 131008  15224 237072    0    0  9112 10324 5086 3568  2 54  0 44
 1  0      0 120160  15224 247784    0    0  5232     0 4976 2935  0 34  0 66
 0  1      0 110424  15224 257404    0    0  4628 12864 5097 3034  4 36  0 60
 1  0      0  86556  15224 281120    0    0 11536     0 4965 3874  3 54  0 43
 1  1      0  73784  15224 293816    0    0  6188 11592 5545 3514  2 46  0 52
 1  1      0  63252  15232 304132    0    0  4968 10320 4617 2748  2 34  0 64
 0  1      0  43148  15232 323960    0    0  9652  7184 5126 3749  2 54  0 43
 0  1      0  29336  15232 337560    0    0  6596 10036 4311 2796  2 38  0 59
 1  1      0  23944  11696 346276    0    0  7480     0 5465 3455  2 46  0 52
 2  1      0  23076   9580 349184    0    0  2860 10524 4521 2323  1 35  0 64
 2  1      0  24440   5300 351508    0    0  8864  5188 4586 3215  1 66  0 33
 0  1      0  24500   3900 352704    0    0  4896 11448 5974 3308  2 49  0 49
 1  1      0  24432   3772 352700    0    0 10424  6208 4851 3682  2 60  0 38
 1  1      0  23764   3772 353736    0    0  6568  5184 5970 3526  1 45  0 53
 1  1      0  24068   3776 353500    0    0  4900 11388 5449 3142  0 40  0 60
 0  1      0  24400   3780 352552    0    0 10068  8848 4821 3531  2 57  0 40
 1  1      0  24152   3772 352588    0    0  8292  2784 5207 3588  2 50  0 48
 1  1      0  23516   3772 353620    0    0  6800  7816 5475 3475  1 49  0 49
 0  1      0  24260   3772 352940    0    0  7004  7424 5042 3284  4 43  0 52
 2  1      0  24068   3776 353060    0    0  4624 10292 4798 2801  0 39  0 61
 2  0      0  23820   3780 353340    0    0  8844  5508 5251 3609  0 56  0 44
 2  1      0  24252   3772 352528    0    0  4552 12000 5053 2841  2 44  0 54
 1  1      0  23696   3772 353120    0    0 10880  2176 4908 3694  2 58  0 40
 1  0      0  24260   3772 352212    0    0  3748 11104 5208 2904  2 34  0 63
 3  2      0  24136   3780 352084    0    0 10148  1628 4637 3568  1 55  0 44
 0  1      0  24192   3780 352120    0    0  4016 10260 4719 2613  1 31  0 68
 1  1      0  24392   3772 352076    0    0  6804 10972 5386 3473  1 52  0 47
 1  1      0  24392   3772 351704    0    0  8568  8788 5101 3502  2 61  0 36
 0  1      0  24376   3780 351764    0    0     0 30036 6711 1888  0 36  0 64
 0  1      0  24252   3780 351928    0    0    28  2072 5629 1354  0 10  0 90
 0  0      0  24768   3780 351968    0    0    40    20 1351  579  9  6 13 72
 1  0      0  24768   3780 351968    0    0     0     0 1073   55  1  1 98  0
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top