1

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.

aliqandil
  • 123
  • 5
  • Why do you use redirects? – Michael Hampton Dec 24 '20 at 03: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 '20 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? – Michael Hampton Dec 24 '20 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 '20 at 10:51
  • What is the actual real world problem, then? – Michael Hampton Dec 25 '20 at 19:38
  • That would be outside of the scope of this question and what I'm looking to get an answer on. in short, there are no real world code breaking problems, only hopes of optimizations. – aliqandil Dec 25 '20 at 23:40
  • There is a real world issue I have encountered right about now is that sometimes TTL is not respected at all. (in my tests, by 3% of the users) – aliqandil Dec 25 '20 at 23:51
  • Yes, a very few DNS servers out there are intentionally broken by their operators so as to ignore the TTL. See my previous comment for what you can do about it. – Michael Hampton Dec 26 '20 at 02:48

0 Answers0