TCP/IP keepalive settings and related DB2 registry variables

Technote (FAQ)

Question

This technote describes how to view and change TCP/IP keepalive settings or DB2 registry variables to: (1) improve detection of when a client or server that is no longer responding or (2) prevent disconnects on idle connections.

Answer

TCP/IP keepalive settings TCP/IP uses operating system keepalive parameters to detect when the client or server side of an idle connection is no longer responding. DB2 sets the TCP/IP keepalive setting on both the client and server by default.

You may wish to decrease the keepalive parameters on the server side machine to improve detection of client failures, or decrease the keepalive parameters on the client side machine to improve detection of server failures. Alternatively, you may wish to increase the keepalive parameters on the server side machine to prevent client disconnects on idle connections, or increase the keepalive parameters on the client side machine to prevent server disconnects on idle connections.

Each keepalive parameter comes with a default setting; many parameters are configurable. In general, the parameters:

Determine how long to wait before probing the idle connection. On most platforms the default is 2 hours.

Determine how long to wait before retrying the probe after initial failure to respond.

Determine the maximum number of times to retry the probe.

Modifying any keepalive parameter may involve trade-offs and affects applications on your entire machine. For example, changing these parameters affects rlogin, ssh, and telnet. You may wish to reset additional TCP/IP parameters, depending on the overall impact to other TCP/IP parameters. Contact your operating system administrator for help with setting these values.

This Technote describes how to display and modify keepalive values on various operating systems. The table below lists the keepalive parameters and operating systems covered by this TechNote.

Table 1: Keepalive Parameters by Operating System

Operating System

Parameter wait time before probing the connection

Parameter interval between retry probes

Parameter maximum retry probes

Unit of measure

AIX

tcp_keepidle (the length of time to keep an idle TCP connection active)

tcp_keepintvl (the interval between packets sent to validate the TCP connection)

n/a

half-seconds

HP-UX 11i

tcp_time_wait_interval (the time that a TCP connection stays in TIME-WAIT state)

tcp_keepalive_interval (the interval between probes)

tcp_keepalives_kill1 (the maximum number of times to probe before dropping)

milliseconds

Linux

tcp_keepalive_time (the interval between the last data packet sent and the first keepalive probe)

Run Regedt32 to edit the Registry file located in HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters.

Enter a new value and choose OK.

Reboot after editing.

DB2 registry variables to help detect when a client or server is not responding

If you do not wish to adjust the keepalive operating system settings, DB2 has additional registry variable settings that you can use to help detect some situations where a client or server is not responding.

DB2CHECKCLIENTINTERVAL - Adjusting this variable on the server determines how quickly the DB2 server can detect a client-server connection has been terminated (for example, a client kills a DB2 application). Setting this variable does not help with situations where the client is not responding because of an abnormal machine termination where TCP cannot respond (operating system keepalive values must be adjusted to handle this condition).

DB2TCP_CLIENT_CONTIMEOUT - Adjust this variable on a client to guarantee that a connection will be established or will fail within a specified amount of time. This is useful when the server is not responding because the machine is
overloaded.

DB2TCP_CLIENT_RCVTIMEOUT - Adjust this variable on the client to terminate the connection if data is not received from the server within a specified amount of time. This is useful in situations where a connection has already been established with the server but the server is no longer responding because the machine is overloaded.

DB2TCP_CLIENT_KEEPALIVE_TIMEOUT - Adjust this variable at the client to override the default system-wide TCP keepalive behavior for all TCP/IP-based database connections and instance attachments. The value specified represents the maximum amount of time in seconds that a connection can remain idle before being considered to have died. For database connections, this registry variable can be overridden by the database-specific KeepAliveTimeout keyword in the db2dsdriver.cfg file. Both settings are supported only on AIX, Linux, and Windows platforms, and are available as of V9.7 FP1.

Note: Because DB2TCP_CLIENT_KEEPALIVE_TIMEOUT is not supported on Solaris. If you are using that platform consider using the tcp_ip_abort_interval parameter, which specifies how long an idle connection will stay open, to identify a network failure or storage outage.

Recommendations for keepalive settings

The suggested value for the keepalive timeout is 15 seconds.

You should set the keepalive timeout either through the registry variable, DB2TCP_CLIENT_KEEPALIVE_TIMEOUT, or through db2dsdriver.cfg file

For additional details on these registry variables, see the
Communications variables topic in the product Information Center at: