Definition of Connect, Processing, Waiting in apache bench

Solution 1:

By looking at the source code we find these timing points:

apr_time_t start,           /* Start of connection */
           connect,         /* Connected, start writing */
           endwrite,        /* Request written */
           beginread,       /* First byte of input */
           done;            /* Connection closed */

And when request is done some timings are stored as:

        s->starttime = c->start;
        s->ctime     = ap_max(0, c->connect - c->start);
        s->time      = ap_max(0, c->done - c->start);
        s->waittime  = ap_max(0, c->beginread - c->endwrite);

And the 'Processing time' is later calculated as

s->time - s->ctime;

So if we translate this to a timeline:

t1: Start of connection
t2: Connected, start writing
t3: Request written
t4: First byte of input
t5: Connection closed

Then the definitions would be:

Connect:      t1-t2   Most typically the network latency
Processing:   t2-t5   Time to receive full response after connection was opened
Waiting:      t3-t4   Time-to-first-byte after the request was sent
Total time:   t1-t5

Solution 2:

From http://chestofbooks.com/computers/webservers/apache/Stas-Bekman/Practical-mod_perl/9-1-1-ApacheBench.html:

Connect and Waiting times

The amount of time it took to establish the connection and get the first bits of a response

Processing time

The server response time—i.e., the time it took for the server to process the request and send a reply

Total time

The sum of the Connect and Processing times

I equate this to:

  • Connect time: the amount of time it took for the socket to open
  • Processing time: first byte + transfer
  • Waiting: time till first byte
  • Total: Sum of Connect + Processing

Solution 3:

Connect: Time it takes to connect to remote host

Processing: Total time minus time it takes to connect to remote host

Waiting: Response first byte receive minus last byte sent

Total: From before connect till after the connection is closed