User Agents

Web browsers and everyday web tech, explained

Load Balance DNS Records: A Practical Guide

· 5 min read · How the Web Works

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Load balancing DNS records distributes incoming traffic across multiple servers, improving availability, performance, and resilience. Instead of pointing a domain to a single IP, you publish several A/AAAA records (or use a load balancer's IPs) and let DNS resolution rotate or prioritize them. This guide walks you through the setup for round-robin DNS and basic health-check-aware load balancing, assuming you have domain access and can edit DNS records.

What You'll Need

  • Access to your DNS hosting provider's control panel (e.g., Cloudflare, AWS Route 53, GoDaddy, Namecheap).
  • At least two servers with static public IP addresses (or a load balancer's IPs).
  • Your domain name's DNS zone is already active.
  • Optional: a monitoring tool or a DNS service that supports health checks.

Step-by-Step

  1. Identify your servers' IPs. Gather the public IPv4 (and IPv6 if using AAAA) addresses of all servers that will serve traffic. Ensure they are static and reachable from the internet.
  2. Decide on a strategy. For simple round-robin, you'll add multiple A records with the same name. For active-passive (failover), you'll use a DNS service that supports health checks and priorities. For advanced load balancing, consider a cloud load balancer (e.g., AWS ELB, Azure Load Balancer) and point DNS to its IP or CNAME.
  3. Log in to your DNS provider. Navigate to the DNS management page for your domain.
  4. Add the first A record. Create a record with hostname (e.g., www or @ for root), type A, and the first server's IP. Set TTL to a low value (300–600 seconds) for faster failover during changes.
  5. Add additional A records. Repeat the same hostname and type, but with the second server's IP. If you have more servers, add them all. Most providers allow multiple records with the same name; if yours doesn't, you may need to use a different load balancing method (see Tips).
  6. Optionally add AAAA records. If your servers support IPv6, add corresponding AAAA records for each IP.
  7. Set TTL appropriately. For round-robin, a TTL of 300–600 seconds is common. For failover, lower TTL (e.g., 60 seconds) helps clients recover faster when a server goes down, but increases DNS query load.
  8. Save and verify. After saving, use a tool like dig, nslookup, or an online DNS checker to query your domain. You should see multiple A records returned in a different order each time (round-robin).
  9. Test failover (if applicable). If you're using a health-check-based service, temporarily stop one server and confirm that DNS stops returning that IP and traffic shifts to the healthy ones.
  10. Monitor and adjust. Keep an eye on traffic distribution. If one server is overloaded, you may need to adjust weights (if supported) or add more records.

Common Mistakes

  • Not using static IPs. Dynamic IPs will break DNS resolution when they change.
  • Ignoring TTL. Leaving a high TTL (e.g., 86400) means changes take up to 24 hours to propagate, delaying failover.
  • Assuming round-robin is true load balancing. DNS round-robin rotates IPs, but it doesn't consider server load or health. A busy server still gets traffic.
  • Forgetting about DNS caching. Clients and recursive resolvers cache DNS results, so even with low TTL, some users may hit a downed server for a while.
  • Mixing CNAME and A records for the same name. This can cause conflicts or unpredictable behavior.

Tips

  • Use a DNS provider with health checks. Services like AWS Route 53, Cloudflare Load Balancing, or NS1 can automatically remove unhealthy IPs from responses, improving reliability.
  • Consider geographic routing. If your audience is global, use GeoDNS to direct users to the nearest server, reducing latency.
  • Combine DNS load balancing with a real load balancer. For HTTP traffic, put a load balancer (e.g., HAProxy, Nginx) in front of your servers and point DNS to its IP. This gives you true load distribution and health checks.
  • Set a low TTL during changes. Lower TTL to 60 seconds before making changes, then raise it back after everything is stable.
  • Use weighted records if available. Some providers let you assign weights to A records, so more powerful servers get more traffic.

Troubleshooting

  • Traffic is not distributing evenly. Check if your provider supports round-robin. Some providers may randomize order, but clients may cache the first IP. Try lowering TTL and testing with a fresh resolver.
  • One server is getting all traffic. Verify that all A records are correctly added and that none are duplicates. Also check if your provider is using a failover mechanism that prioritizes one IP.
  • DNS changes are not showing up. Wait for TTL to expire, or flush your local DNS cache. Use dig +trace to see the full resolution path.
  • Server is down but still receiving traffic. This happens with pure round-robin because DNS doesn't check health. Switch to a health-check-based service or implement a monitoring script that updates DNS records when a server fails.
  • Cannot add multiple A records. Some DNS hosts (rare) only allow one record per name. Use a subdomain per server (e.g., server1.example.com) and then use SRV records or a load balancer CNAME instead.

Frequently Asked Questions

Q: Does DNS round-robin actually balance load?
A: It distributes connections roughly evenly across IPs, but it doesn't consider server capacity or current load. It's best for simple redundancy, not for fine-grained load balancing.

Q: What is the difference between round-robin and failover?
A: Round-robin rotates through all IPs equally. Failover prioritizes a primary server and only uses backups when the primary is down, often via health checks.

Q: Can I use DNS load balancing for a database?
A: It's not recommended for databases that require session consistency or write operations. DNS load balancing is best for stateless services like web servers or APIs.

Q: How low can I set my TTL?
A: Most providers allow 30–60 seconds. Lower TTLs mean faster failover but more DNS queries. Very low TTLs (e.g., 1 second) are usually unnecessary and can burden DNS servers.

Q: Will DNS load balancing work with SSL certificates?
A: Yes, as long as your SSL certificate covers the domain name (e.g., *.example.com or example.com) and is installed on all servers. If using a load balancer, terminate SSL there.

Q: How do I know if my DNS provider supports health checks?
A>Check your provider's documentation or look for features like "load balancing," "health checks," or "failover" in the DNS settings. If not, you can use a third-party DNS service that offers these features.