tags:

views:

732

answers:

1

The nginx documentation says

max_clients = worker_processes * worker_connections

but how does the keepalive factor into this? I have my configuration setup with 2 worker_processes and 8192 worker_connections; that means I can theoretically handle a maximum of 16384 concurrent connections. Pushing out 16384 streams of data concurrently is ginormous, but if I have a 60s keepalive_timeout then with each client hogging a connection for 1 minute that number has a completely different meaning. Which is it?

Connected to all this is the $connection variable that can be used with the log_format directive. I defined the following log format so I could analyze the server's performance:

log_format  perf  '$request_time $time_local $body_bytes_sent*$gzip_ratio $connection $pipe $status $request_uri';

That $connection variable is reporting around 11-12 million connections! I'm no math major, but obviously that number is way higher than worker_processes * worker_connections. So what is it supposed to represent?

In short, I'm trying to figure out how to determine a good value for worker_connection.

+1  A: 

$connection is a counter, not the total number of used connections right now. So it's intended to grow.

Keepalive connections cannot be discarded, so the room is worker_processes * worker_connections - keepalive connections

rzab
A counter! Now that you say it I can see the pattern. Thank you for answering such an obscure question.
Daniel