Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Bench: Mean vs Mean across all concurrent requests

Tags:

apachebench

What is the difference between those 2 fields? :

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

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?

like image 243
Omar S. Avatar asked Mar 31 '13 14:03

Omar S.


People also ask

What is concurrency in Apache benchmark?

In simple words, ab -n 1000 -c 5 http://www.example.com/ where, -n 1000: ab will send 1000 number of requests to example.com server in order to perform for the benchmarking session. -c 5 : 5 is concurrency number i.e. ab will send 5 number of multiple requests to perform at a same time to example.com server.

How Apache bench works?

ApacheBench allows you to configure the number of requests to send, a timeout limit, and request headers. ab will send the requests, wait for a response (up to a user-specified timeout), and output statistics as a report.


2 Answers

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

like image 58
Will Huang Avatar answered Sep 29 '22 22:09

Will Huang


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

like image 21
swmcdonnell Avatar answered Sep 29 '22 22:09

swmcdonnell