# Socket Connection Properties

Jigsaw Home / Documentation Overview

Here we describe the use of the four sliders used in the SocketConnectionProp to tune Jigsaw according to the load level of your server.

This document has the following sections:

- Client handling
- Load map
- Load level behaviour

# Client handling

When a browser connects to Jigsaw, it will create a new connection, called "Client" in the server, this Client is taken from the pool of free clients of the SocketConnectionFactory.

The client may be used for multiple request on the same connection, "keep-alive" connections are handled by the factory, instead of using fixed timeouts, thus allowing better control of the load and a better handling of persistent connections.

There are two lists used by the factory:

Free Clients
  The list of free clients, clients are created on the fly, but instead of going through the expensive creation process, they are stored when they are available. A new client is always added to this list first before being used.
Idle Clients
  The list of idle clients, the clients already bound to a connection in "keep-alive" mode and waiting for a new request on this connection.

The number of Clients is limited, so are the number of free clients and idle clients. The repartition of the clients on those lists depends on the load of the server and the settings, the server will adapt its behaviour depending on those settings.

# Load map

The load map is:

This is the behaviour as of Jigsaw 2.0.3, it may be modified to enhance the smoothness of the server.
The "Dead" level is obtained when the number of free clients is 0.

# Load level behaviour

Depending on the load level, the server will have a different behaviour. Here is a small description of what happens:

Light
  New clients are always accepted
Average
  New clients are accepted, and some idle clients are shut down. The number of idle clients that will be shut down is the amount to set the freeCount to maxFree.
High
  Same as average, but the "accept thread" priority is lowered, so that "clients" may finish their job first.
Dead
  Connections are refused (Overloaded entries in the errlog).

A good tool to see the number of established connection to your machine is "netstat". If you have statistics on the usage and the maximal number of established connections, using a very large configuration, you may then adjust the settings to lower the resources used.

Rules of thumb:

- maxClients - maxFree should be close to the maximum of established connections, (usually a bell curve on a week day).
- more soon ;)