A records and round robin DNS
Learn about A records and round robin DNS.
A DNS A record is an entry that holds a hostname and the corresponding IP address. You can have multiple A records for different IP addresses using the same hostname as follows (the brokers also have their own FQDNs):
; PRIMARY CLUSTER first.primary.kafka.fqdn. IN A 18.104.22.168 second.primary.kafka.fqdn. IN A 22.214.171.124 third.primary.kafka.fqdn. IN A 126.96.36.199 ; DNS alias primary.kafka.cluster.hostname. IN A 188.8.131.52 primary.kafka.cluster.hostname. IN A 184.108.40.206 primary.kafka.cluster.hostname. IN A 220.127.116.11
If you try to resolve
primary.kafka.cluster.hostname multiple times with any
tools (nslookup, dig), you will get different results each time. This is called round robin load
balancing, which is used by the DNS server automatically.
/etc/hosts file holds the IP address and hostname mappings (similar to A
records in DNS servers), but it is not capable of balancing. You always get the same IP if you
try to resolve the same hostname.
In production environments, a low TTL might be used for DNS records for the clients to detect changes as early as possible.