omars
omars

Reputation: 8684

Apache Bench: Mean vs Mean across all concurrent requests

What is the difference between those 2 fields? :

How is each of them calculated?

Sample Output:

Time per request:       3953.446 [ms] (mean)
Time per request:       39.534 [ms] (mean, across all concurrent requests)

Why is there much difference?

Upvotes: 47

Views: 11082

Answers (3)

dan carter
dan carter

Reputation: 4341

The first figure is simply the second figure times the concurrency level.

As per the man page

Time per request
 The average time spent per request. The first value is calculated with the formula concurrency * timetaken * 1000 / done
 while the second value is calculated with the formula timetaken * 1000 / done

For instance

ab -g dan -n 9 -c 3

Concurrency Level:      3
Time taken for tests:   14.407 seconds
Complete requests:      9
Failed requests:        0
Total transferred:      5255289 bytes
HTML transferred:       5250123 bytes
Requests per second:    0.62 [#/sec] (mean)
Time per request:       4802.437 [ms] (mean)
Time per request:       1600.812 [ms] (mean, across all concurrent requests)
Transfer rate:          356.22 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:      527  550  19.5    549     590
Processing:  2262 3175 756.1   3112    4452
Waiting:     1141 1529 314.7   1506    2178
Total:       2789 3725 755.5   3654    4994

Time per request = Concurrency * time taken for tests / requests done

3 * 14.407 / 9 = 4.802437s

Time per request (across all concurrent) = time taken for tests / requests done

14.407s / 9 = 1.600812s per request

For what it is worth, i find the mean total request time of 3725 a more useful measure. This is simply the sum of each request time divided by the number of requests, or as i would call it average latency

If you run ab with the -g option, it will log each requests individual timing which can be useful for small runs to understand what ab is trying to tell you.

Upvotes: 1

Will Huang
Will Huang

Reputation: 3586

Here is an example of an ab's test result. I make 1000 requests that with 3 concurrent requests.

C:\>ab -d -e a.csv -v 1 -n 1000 -c 3 http://www.example.com/index.aspx
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.121.2.12 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking www.m-taoyuan.tw (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Finished 1000 requests


Server Software:        Microsoft-IIS/6.0
Server Hostname:        www.m-taoyuan.tw
Server Port:            80

Document Path:          /index.aspx
Document Length:        25986 bytes

Concurrency Level:      3
Time taken for tests:   25.734375 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      26372000 bytes
HTML transferred:       25986000 bytes
Requests per second:    38.86 [#/sec] (mean)
Time per request:       77.203 [ms] (mean)
Time per request:       25.734 [ms] (mean, across all concurrent requests)
Transfer rate:          1000.72 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   4.4      0      15
Processing:    62   75   9.1     78     109
Waiting:       46   64   8.0     62     109
Total:         62   76   9.3     78     109

As you can see, there are two Time per request field.

  • Time per request (mean)
  • Time per request (mean, across all concurrent requests)

Please check the Time taken for tests field first. The value is 25.734375 seconds which is 25734.375 ms.

If we divide 25734.375 ms by 1000, you get 25.734 [ms] which is exact the Time per request (mean, across all concurrent requests) field's value.

For the Time per request (mean), the value is 77.203 [ms]. The value is a bit longer than Time per request (mean, across all concurrent requests). That is because the (mean) is counted by every specific request and calculate it's mean time.

Let me give you an simple example.

Assume that we make 3 requests with 3 concurrent connections. The Time taken for tests will be 90ms and each request are 40ms, 50ms, 30ms. So what's the value of these two Time per request?

  • Time per request (mean) = ( 40 + 50 + 30 ) / 3 = 40ms
  • Time per request (mean, across all concurrent requests) = 90 / 3 = 30ms

Hope you can understand. :)

Upvotes: 32

swmcdonnell
swmcdonnell

Reputation: 1421

It would be helpful to see your input, but, I believe the output is telling you that there is no time savings for performing concurrent requests.

Time per request (mean) tells you the average amount of time it took for a concurrent group of requests to process.

Time per request (mean, across all concurrent requests) tells you the average amount of time it took for a single request to process by itself.

If you processed 100 requests concurrently, it took 3953.446ms.

If you processed them individually, it would take 39.534ms * 100 = 3953.4ms

Same number. There is no time savings to performing concurrent requests (at least for the total number of requests you tested).

Upvotes: 22

Related Questions