Each incoming connection is assigned to a specific worker – a
thread in the running program which becomes responsible for processing
requests that arrive through this connection. The total number of
running workers is controlled by three configuration parameters:
WorkerMinCount, WorkerMaxCount, and
WorkerIdleTimeout.
The value of WorkerMinCount defines the minimum number of
workers that should always be running (5, by default). Another
parameter, WorkerMaxCount sets the upper limit on the number of
running workers (it defaults to 128).
At each given moment, a worker can be in one of two states: idle
or active (processing a connection). If an incoming connection
arrives when all running workers are active, and total number of
workers is less than WorkerMaxCount, a new worker thread is
started and the new connection is assigned to it. If the number of
active workers has already reached maximum, the connection enters
the connection queue, where it will wait for a worker to become
available to process it.
The third parameter, WorkerIdleTimeout, specifies maximum time
a thread is allowed to spend in the idle state. If a worker
remains idle longer than that and total number of workers is greater
than the allotted minimum (WorkerMinCount), this idle worker is
terminated.
Maximum capacity of the connection queue is computed as a function of
the system limit on the number of open files and the value of
WorkerMaxCount. You can define it explicitly using the
ConnectionQueueSize configuration statememt (see ConnectionQueueSize).
If all workers are busy and the connection queue is filled up, the program will stop accepting new connections until at least one worker becomes available again.