When you set up a multi-subnet cluster, whether it’s a Failover Cluster Instance or an Availability Group, you need to make sure you understand a few things in order for your applications to work properly after a failover. For the sake of our discussion, let’s assume we have a multi-subnet cluster that spans two data centers, and each data center holds one node.
RegisterAllProvidersIP is a property of the cluster, which defines whether all of the addresses will be registered in DNS, or only the active one.
Those addresses are:
- The two Virtual IPs in the case of a Multi-Subnet Failover Cluster Instance
- The two Listeners in the case of a Multi-Subnet Availability Group
If RegisterAllProvidersIP is off:
Only the active address will be sent to the client. When a failover occurs, Windows Clustering refreshes the DNS record with the new address.
The problem: Each DNS record has a Time to Live (TTL) that is sent with it to the client. Its value is 20 minutes by default. After a client gets the DNS record, it won’t query for a new record until additional 20 minutes pass. This means that if a failover occurs a minute after the client got the DNS record, it won’t be able to connect to the active node for the next 19 minutes.
Each cluster has a property that controls this. It’s called HostRecordTTL, and by reducing it, you reduce the amount of time your clients won’t be able to connect after a failover.
If RegisterAllProvidersIP is on:
Addresses from both data centers will be registered in DNS, and a client querying DNS for the address will get two DNS records.
The problem: The client has to be aware of that, because if not, it will try to connect to only one of the addresses, which might not be the active one. In order to make the client aware of that, you need to set MultiSubnetFailover = True in the client connection string. In that case, the client will try to connect to all of the addresses in parallel.
You won’t be able to set MultiSubnetFailover = True in the following cases:
- Your application is older than .Net 4.0
- Your development team won’t go and add this property to all connection strings in all of the applications
To make things easier to understand, here’s a visualization:
The post How to Make Sure Your Clients Can Connect to a Multi-Subnet Cluster appeared first on .