0

Option at ab linux command for benchmark is described at http://linux.die.net/man/1/ab,

-n number of request -c number of concurrency

for example command to get statistic result on requesting index.html (file size=5937 bytes)

  ab -n 1000 -c 1000 http://localhost:8000/ and show the output as follows

My question is the command execute 1000 concurrent process to get the index.html in 1000 times from one nodejs process at the same start time Right ? Why I need to specify -n 1000 ? How to describe the command with -n 1000 and -c 1000 together ? I believe -n option is set just for number of request re-try if previous request is failed for one process request. Right ?

    The command output on apache Centos
    ==================================
    Server Hostname:        localhost
    Server Port:            8000

    Document Path:          /
    Document Length:        5937 bytes

    Concurrency Level:      1000
    Time taken for tests:   0.725 seconds
    Complete requests:      1000
    Failed requests:        0
    Write errors:           0
    Total transferred:      6052000 bytes
    HTML transferred:       5937000 bytes
    Requests per second:    1378.45 [#/sec] (mean)
    Time per request:       725.455 [ms] (mean)
    Time per request:       0.725 [ms] (mean, across all concurrent requests)
    Transfer rate:          8146.83 [Kbytes/sec] received

    Connection Times (ms)
                min  mean[+/-sd] median   max
    Connect:        0   21  30.0      0      83
    Processing:    25  135  74.2     94     286
    Waiting:       24  135  74.2     93     286
    Total:         54  156  80.3    131     351

    Percentage of the requests served within a certain time (ms)
    50%    131
    66%    227
    75%    238
    80%    242
    90%    257
    95%    266
    98%    269
    99%    272
    100%    351 (longest request)
aabb
  • 113
  • 9

1 Answers1

0

-n is how many requests to make in total. -c is how many requests to make simultaneously. If -c is less than -n, then not all the requests will be done at once. For example:

-n 1000 -c 100 would immediately make 100 requests. When one request completes, another is started until 1000 requests have been sent.

Dark Falcon
  • 43,592
  • 5
  • 83
  • 98
  • so you mean 1000*1000 process request to start at the same time ? – aabb Sep 03 '14 at 12:18
  • what is different (-n 10 -c 1000) and (-n 1000 -c 1000) with same -c ? – aabb Sep 03 '14 at 12:19
  • No. Stop thinking simultaneous requests. `ab` doesn't always make all its requests simultaneously. – Dark Falcon Sep 03 '14 at 12:19
  • `-n 10` means only 10 requests are ever sent to the server. – Dark Falcon Sep 03 '14 at 12:20
  • So it just 1000 request ? why need to set -n ? – aabb Sep 03 '14 at 12:21
  • No, NOT 1000. `-n 10` makes TEN requests. – Dark Falcon Sep 03 '14 at 12:21
  • why not ab -n 1000 instead of ab -n 1000 -c 1000 ? – aabb Sep 03 '14 at 12:22
  • Because then `-c` would default to its default value, which is probably not 1000. – Dark Falcon Sep 03 '14 at 12:22
  • The question go to -c option, why need to set -c ? – aabb Sep 03 '14 at 12:22
  • To control how many are sent AT THE SAME TIME. You do understand time, right? That not everything happens at once? That things can be slowed down or delayed? – Dark Falcon Sep 03 '14 at 12:24
  • may be I know it concurrent level=2 (-c 2) and total request=10 (-n=10) that mean try to make total 10 request within 2 concurrent level that mean is depended how to apache to handle concurrent level – aabb Sep 03 '14 at 12:27
  • (-n 10 -c 2) it is same to use 2 process to request 10 request, one process to handle 5 request – aabb Sep 03 '14 at 12:30
  • it seems your question answer on post sounds correct – aabb Sep 03 '14 at 12:36
  • node.js uses non-blocking i/o, which means that usually a small, fixed number of processes handle all requests not matter how many. `ab` works the same way. One process is used to make all the requests using non-blocking i/o. For more information about this, check the documentation for `select` or `poll`. The overall behavior is as described above, however. `-c` requests are made simultaneously and `-n` requests are eventually sent. – Dark Falcon Sep 03 '14 at 12:38
  • it is good link to describe non-block I/O nodejs at http://stackoverflow.com/questions/10570246/what-is-non-blocking-or-asynchronous-i-o-in-node-js – aabb Sep 03 '14 at 12:50