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       1.2.3.4
second.primary.kafka.fqdn.         IN  A       4.5.6.7
third.primary.kafka.fqdn.          IN  A       6.7.8.9

; DNS alias
primary.kafka.cluster.hostname.    IN  A       1.2.3.4
primary.kafka.cluster.hostname.    IN  A       4.5.6.7
primary.kafka.cluster.hostname.    IN  A       6.7.8.9

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.

The /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.