AI Briefing
KO

Implementing Redis HA Using DNS TTL 0 Configuration

·2016.03.18 00:00

Key point

This DNS TTL 0-based Redis HA approach restores connections by immediately switching the domain IP to a slave upon master failure.

1 / 2

Details

Instead of complex clustering, this approach proposes a Redis HA method that sets the DNS TTL (Time To Live) value to 0 to respond immediately to domain changes. When a master server failure is detected, the IP of the primary domain is changed to the slave server, and thanks to the TTL 0 setting, clients can immediately reconnect to the latest IP without caching.

During the failover process, the following steps are executed sequentially: disabling read-only mode on the slave (slave-read-only no), changing the domain, disconnecting existing connections from the old master (CLIENT KILL TYPE normal), promoting the slave to master (slaveof no one), and rewriting the configuration file (CONFIG REWRITE).

Key considerations include separating a dedicated DNS server or using client connection pools to reduce DNS server load caused by TTL 0. Additionally, in Java environments, domain caching in the JVM must be disabled using the -Dsun.net.inetaddr.ttl=0 option, and if using twemproxy, version 0.4.1 or higher with IP re-resolution capabilities is required.

This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.

Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.