Timeout behavior of the Linux application server
Various types of timeout related to the Linux application server are discussed in this topic.
On Linux, you can display
your current network attribute values by viewing the contents of the corresponding files in the
directory /proc/sys/net/ipv4. Changing the file contents changes the parameter
values.
To avoid negative effects on system performance, it is recommended that you change the default
values only after careful study. A description of the different options can be found under the
Linux Source Tree in the file
linux/Documentation/networking/ip-sysctl.txt.
Client connection timeout
When the client connects to the server, each connection attempt times out after a time period determined by the value of the network attribute tcp_syn_retries. When this happens, the connect attempt has failed. The client then writes an error message and returns the error to the calling process. The default value for tcp_syn_retries is 6, which corresponds to about 180 seconds. This means that a Linux connection request times out after 180 seconds. For an example where you might need to change this default, see Additional considerations.
This setting is system-wide and affects all TCP connections that are established from the system.
For the relationship between the setting of the TCP/IP client connection timeout and the Db2® connection timeout, see Timeout behavior of Db2 client connections.
Client transmission timeout
Each time the client sends data to the server, TCP/IP waits for acknowledgment of this data. TCP/IP retransmits data if acknowledgments are missing. The time period that TCP/IP waits for the acknowledgment before it times out is variable and dynamically calculated. This calculation uses, among other factors, the roundtrip time measured on the connection. The timeout interval is doubled with each successive retransmission (called exponential backoff). When the final transmission timeout occurs, the client's next receive call fails with a send timeout error. The client writes an error message and returns the error to the calling process.
On Linux, the number of retransmissions is determined by the value of the network attribute tcp_retries2. The default value is 15, which corresponds to about 13-30 minutes depending on RTO.
Recommended values: For the client
transmission timeout, it is recommended that you change the value
of tcp_retries2 to 8. This reduces the timeout
to approximately 4 minutes.
Client idle timeout
If there is no data flow on a client/server connection, TCP/IP uses a so-called keep-alive mechanism to verify that such an idle connection is still intact after a predefined period of time. The term idle means with respect to TCP/IP, and includes the case where the client is waiting in the recv() function because this wait for data is a passive task and does not initiate any packet transfers for itself. If the remote system is still reachable and functioning, it will acknowledge the keep-alive transmission. On Linux, this mechanism is controlled by the network attributes tcp_keepalive_time (default is 2 hours), tcp_keepalive_probes (default value is 9) and tcp_keepalive_intvl (default value is 75 seconds). The default values of these network attributes determine that an idle connection is closed after about 2 hours and 11 minutes if no keep-alive probes are acknowledged.
Recommended values: It is recommended that these network attributes be set as follows:
- tcp_keepalive_time to 600 half-seconds (5 minutes)
- tcp_keepalive_intvl to 6 seconds.
This results in approximately 5 minutes + (9 * 6) seconds = 5 minutes and 54 seconds.