Non-Java client support for high availability for connections to Db2

Db2 servers provide high availability for client applications, through workload balancing and automatic client reroute. This support is available for applications that use non-Java clients (ODBC, CLI, .NET, OLE DB, PHP, Ruby, or embedded SQL), as well as Java™ clients (JDBC, SQLJ, or pureQuery).

For non-Java clients, you must use one of the listed clients or client packages to take advantage of high availability support:
  • IBM® Data Server Client
  • IBM Data Server Runtime Client
  • IBM Data Server Driver Package
  • IBM Data Server Driver for ODBC and CLI
High availability support for connections to Db2 servers includes:
Automatic client reroute
This support enables a client to recover from a failure by attempting to reconnect to the database through an alternate server. Reconnection to another server is called failover. Client support for automatic client reroute is enabled by default for non-Java clients that connect to Db2.

Servers can provide automatic client reroute capability in any of the following ways:

  • Several servers are configured in a Db2 pureScale® instance. A connection to a database is a connection to a member of that Db2 pureScale instance. Failover involves reconnection to another member of the Db2 pureScale instance. This environment requires that clients use TCP/IP to connect to the Db2 pureScale instance.
  • A Db2 pureScale instance and an alternate server that is defined for a database. Failover first involves reconnection to another member of the Db2 pureScale instance. Failover to the server is attempted only if no member of the Db2 pureScale instance is available.
  • A Db2 pureScale instance is defined for the primary server, and another Db2 pureScale instance is defined for the server. Failover first involves reconnection to another member of the primary instance. Failover to the alternate instance is attempted only if no member of the primary Db2 pureScale instance is available.
  • A database is defined on a single server. The configuration for that database includes specification of an alternate server. Failover involves reconnection to the alternate server.

Alternate groups are an additional failover mechanism for automatic client rerouting when connectivity to the current group cannot be re-established. A group is a database that is created in a Db2 instance. In Db2 pureScale or partitioned database environments, all the participant database servers for a database are also considered a group. The database to which your application explicitly connects to is called the primary group.

For CLI or .NET client applications, failover for automatic client reroute can be seamless or non-seamless. With non-seamless failover, when the client application reconnects to another server an error is always returned to the application to indicate that failover (connection to the alternate server) occurred. With seamless failover, the client does not return an error if a connection failure and successful reconnection to an alternate server or alternate group occurs during the execution of the first SQL statement in a transaction.

In a Db2 pureScale instance, you can use automatic client reroute support without workload balancing or with workload balancing.

Workload balancing
Workload balancing can improve the availability of a Db2 pureScale instance.

With workload balancing, a Db2 pureScale instance ensures that work is distributed efficiently among members.

Workload balancing against a Db2 pureScale server can be enabled on the server side by setting the member subset attributes to a value of wlb. See WLM_CREATE_MEMBER_SUBSET procedure - Create a member subset object

Non-Java clients on any operating system support workload balancing. The connection from the client to the Db2 pureScale instance must use TCP/IP.

When workload balancing is enabled, the client gets frequent status information about the members of the Db2 pureScale instance through a server list. The client caches the server list and uses the information in it to determine the member to which the next transaction should be routed.

For non-Java clients, the server list is cached in the application process. It is shared for workload balancing only by connections in that process.

Db2 supports two types of workload balancing:
Connection-level workload balancing
Connection-level workload balancing is performed at connection boundaries. It is supported only by non-Java clients. Client support for connection-level workload balancing is enabled by default for non-Java clients that connect to Db2.

Connection-level load balancing is most effective for connections whose duration is short.

Transaction-level workload balancing
Transaction-level workload balancing is performed at transaction boundaries. Client support for transaction-level workload balancing is disabled by default for clients that connect to Db2.

Transaction-level load balancing is most effective for connections whose duration is long.

Client affinities
Client affinities is an automatic client reroute solution that is controlled completely by the client. It is intended for situations in which you must connect to a particular primary server. If an outage occurs during the connection to the primary server, you use client affinities to enforce a specific order for failover to alternate servers.