User Agents

Web browsers and everyday web tech, explained

Load Balance DNS: Round-Robin Setup Guide

· 6 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 spreads incoming traffic across multiple servers by returning different IP addresses for the same hostname. This improves availability, distributes load, and provides basic failover without dedicated hardware. It works best for stateless services (web, API, static files) and is simpler than anycast or global server load balancing. Before starting, you need: a domain with DNS management access, at least two servers with static IPs running your service, and the ability to edit DNS records (usually A or AAAA records).

What You'll Need

  • A domain name with DNS hosting (registrar or third-party like Cloudflare, Route 53, or your own BIND server)
  • Two or more servers with static public IP addresses, all running the same service (e.g., web server)
  • Access to the DNS control panel or zone file
  • Optional: a monitoring script or uptime check to detect server failures

Step-by-Step

  1. Verify server health – Confirm each server responds correctly to requests (e.g., curl http://server1-ip). Ensure all servers serve identical content or can handle any request.
  2. Choose your DNS provider – Use your current DNS host. If you need more control (like TTL adjustments), consider a provider that allows low TTL (30–300 seconds).
  3. Create multiple A records – For the same hostname (e.g., www.example.com), add one A record per server IP. Do not use CNAME for this; use A (or AAAA for IPv6). Example: www.example.com A 203.0.113.10 and www.example.com A 203.0.113.11.
  4. Set the TTL – Lower the TTL (time-to-live) to 300 seconds (5 minutes) or less. This allows faster propagation when you change IPs. Many providers allow per-record TTL.
  5. Save and wait for propagation – DNS changes take time. Check with a tool like dig or nslookup from different networks. Use dig www.example.com and look for multiple A records in the answer section.
  6. Test the rotation – Run dig www.example.com several times. You should see the IPs rotate or be returned in a different order. Note: some resolvers cache the order, so use a fresh resolver or clear cache.
  7. Implement failover (optional) – Basic round-robin does not remove dead servers. To fail over, you need a health check that updates DNS. Many providers offer “load balancing” or “health check” features (e.g., Cloudflare Load Balancing, AWS Route 53). If using plain round-robin, you must manually remove a dead IP when a server fails.
  8. Monitor and adjust – After a few days, review server logs to see traffic distribution. If one server gets more traffic (due to resolver caching), you may need to adjust TTL or use weighted records if your provider supports them.

Common Mistakes

  • Using CNAME for multiple IPs – CNAME points to a name, not an IP. You cannot have multiple CNAMEs for the same hostname, and it won’t load balance.
  • Not setting a low TTL – If TTL is 86400 (24h), changes take a full day to propagate. For load balancing, you need low TTL to react to failures.
  • Forgetting to update all servers – If one server runs an old version, users may get inconsistent results. Keep code and content in sync.
  • Assuming round-robin equals high availability – Without health checks, a down server will still receive traffic. You must monitor and remove dead IPs manually or use a provider’s health check.
  • Ignoring session persistence – If your app uses sticky sessions (e.g., shopping carts), round-robin can break them. Use a load balancer with session affinity or make your app stateless.
  • Not testing from multiple locations – Your local DNS may cache results, making it look like only one IP is returned. Use online DNS checkers.

Tips

  • Use weighted records if available – Some providers (e.g., AWS Route 53, Azure DNS) let you assign weights to A records, so you can send more traffic to a larger server.
  • Combine with anycast for global performance – If you need low latency worldwide, consider anycast (e.g., Cloudflare) instead of simple round-robin.
  • Set up a simple health check script – A cron job that pings each server and updates DNS via API can automate failover. But be careful: if the DNS provider API is down, you could have issues.
  • Keep TTL low during changes – When adding or removing servers, lower TTL to 60 seconds temporarily, then raise it back after changes settle.
  • Use separate hostnames for different services – For example, api.example.com vs www.example.com, so you can balance them independently.
  • Document your IPs and server roles – This helps when troubleshooting or when you need to remove a server quickly.

Troubleshooting

  • Only one IP is returned – Check that you added all A records correctly. Run dig www.example.com. If only one IP shows, your DNS provider may be doing “round-robin” differently (some return all records but in a fixed order). Try a different resolver (e.g., 8.8.8.8) or clear your local cache.
  • Traffic is not distributed evenly – This is normal. Many resolvers cache the first IP they receive and stick to it. Over time, with many resolvers, distribution averages out. If it’s wildly uneven, check if your provider supports “random” ordering or weighted records.
  • One server goes down, but users still get its IP – Round-robin does not detect failures. You must manually remove the A record or use a health-check-based load balancer. Alternatively, set up a monitoring script that updates DNS when a server fails.
  • DNS changes are not propagating – Wait for TTL to expire. Use dig against authoritative nameservers (e.g., dig @ns1.provider.com www.example.com). If the authoritative server shows the new records, propagation is just slow.
  • Users report errors or mixed content – Ensure all servers serve the same version of your site. Check that HTTPS certificates are valid on every IP (you may need a wildcard cert or multiple SANs).
  • Some users cannot access the site at all – Check if one of your IPs is blocked or unreachable from certain networks. Use a global uptime checker to see if any IP is failing.

Frequently Asked Questions

  • Does round-robin DNS work for email servers? – Yes, but it’s risky. Email servers (MX records) use priority, not round-robin. For SMTP, you should use multiple MX records with different priorities, not A records. For web, round-robin is fine.
  • Can I load balance HTTPS with round-robin DNS? – Yes, but each server must have a valid SSL certificate for the domain. Use a wildcard certificate or ensure all servers have the same cert.
  • What is the difference between round-robin and geo DNS? – Round-robin returns IPs in rotation regardless of user location. Geo DNS returns the closest server based on the user’s IP. Geo DNS requires a provider that supports it (e.g., Route 53, Cloudflare).
  • How many servers can I use? – There is no hard limit, but each additional A record adds to DNS response size. In practice, 5–10 is fine. For more, use a dedicated load balancer or anycast.
  • Will round-robin DNS break if a server is down? – Yes, it will still send traffic to the down server. You need a health check to remove the IP. This is why many people use a cloud load balancer instead.
  • Can I use IPv6 with round-robin? – Yes, add multiple AAAA records. Some providers allow a mix of A and AAAA. Ensure your servers have IPv6 connectivity.