Premise: I'm facing an issue with load balancing with my own custom DNS server, over multiple web servers. My intention is to be able to quickly and dynamically switch the users I want between different servers by giving them new "A Records".

What I've tried: The current workaround is Using a Short TTL (1min), and temporary redirects from the old servers for the duration of that minute to the same subdomain but with a cache breaking value added to it. (s-00001.example.com -> s-0001-TIMESTAMP.example.com) But that solution is not efficient as it causes lots of needless DNS queries since I rarely need to do such a switcheroo! and it makes the old server that was already under some load, to not be fully alleviated of it since it still needs to serve the redirects for a minute.

But I have seen that when I respond with a 404 Error, Chrome and Firefox both will attempt another DNS lookup. so this will solve the problem, but still a 404 will interrupt the normal actions of my site for that one request. Also I have not tested this system with other browsers, and I do not think this is a feature Web Developers should depend on.

Question: I would like to know which status codes will provide the best results consistently over different browsers, and which ones make more sense. and also, if you have any other suggestions / workarounds, I'd love to hear them.

ps: I do know that DNS is not the best option for load balancing alone, but this is the current situation that I'm in.

  • Why do you use redirects? Dec 24, 2020 at 3:16
  • so I can redirect to another subdomain, to force a new dns lookup. (the same thing in web-apps is called cache breakers if I'm not wrong.)
    – aliqandil
    Dec 24, 2020 at 13:20
  • Why are you using other subdomains, then? This whole scheme doesn't seem to be necessary, top to bottom. Why aren't you just serving the site from both network addresses for that short time while the DNS is being changed? Dec 24, 2020 at 20:07
  • That is not the issue, using a redirect to a cache-broken subdomain, or serving from both network addresses are both valid "workarounds", but does not solve other issues, like for example I still would have to use a short TTL. I'm not attemping to "solve" a real world problem since the current workaround I have Is well, working, I'm attemping to find a cleaner and more optimized way to ask browsers to attempt a new dns loopup before the TTL is passed. (something Chrome and Firefox sometimes do on 404 responses)
    – aliqandil
    Dec 25, 2020 at 10:51
  • What is the actual real world problem, then? Dec 25, 2020 at 19:38


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.