You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by S Ahmed <sa...@gmail.com> on 2011/12/23 18:03:05 UTC

[users@httpd] apache bench -k switch

When I add the -k switch during my benchmarks, my requests per second
increases substantially.

Can someone explain to me what -k does?

Is it simply re-using the sockets opened?

Is it more or less realistic (mimics real world traffic) to have the -k
switch?

Re: [users@httpd] apache bench -k switch

Posted by Mark Montague <ma...@catseye.org>.
On December 23, 2011 12:03 , S Ahmed <sa...@gmail.com> wrote:
> When I add the -k switch during my benchmarks, my requests per second 
> increases substantially.
>
> Can someone explain to me what -k does?

 From the ab man page:

>        -k     Enable  the  HTTP  KeepAlive  feature,  i.e.,  perform  
> multiple
>               requests within one HTTP session. Default is no KeepAlive.


> Is it simply re-using the sockets opened?

It sends multiple HTTP requests over a single connection to the web 
server.  This involves not only keeping the socket open, but also 
signaling to the server that the client supports keepalive.  The server 
may choose not to allow keepalive even if the client supports it.  The 
server may choose to limit the number of requests on a single 
connection, or the maximum time it will wait for a subsequent request.

See the Apache HTTP Server documentation for the following directives:  
KeepAlive, KeepAliveTimeout, MaxKeepAliveRequests.

A more detailed description is available at 
https://en.wikipedia.org/wiki/HTTP_persistent_connection


> Is it more or less realistic (mimics real world traffic) to have the 
> -k switch?

It depends on whether the browsers that are generating your real world 
traffic are using keepalive or not.  Also, if it's important to mimic 
real world traffic, then you would want a more sophisticated 
benchmarking tool than ab so that you can not only mimic keepalives, but 
also control the number of requests per connection, the time between 
requests, request pipelining, and how long a connection is held open by 
the client after the last request on it.

--
   Mark Montague
   mark@catseye.org


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org