New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
one domain - 2 ips - fastest server response
Hello,
im not sure how to do this:
i have a domain and 2 server with almost the same hardware specs and i want to configure the domain that both servers should be asked and the fastest server should response. Its just a small hobby project so it should be free or atleast a cheap option im searching for.
thanks
Comments
Easiest and simplest would be DNS round robin.
Not exactly what you asked for but close.
Thanks. Hows that done for example with dns servers and the fastest one is answering you? Is this also done with dns round robin?
Can this not be done with haproxy?
http://www.haproxy.org/
Just configure both the servers to work for your domain name using whichever panel you use.
In the DNS create two "A" record instead of one for the same key, each "A" record will point to one of the two servers.
What it does essentially is, as soon as browser will see multiple DNS lookup for same key is present, it will randomly pick one of them and use that to resolve to whichever server value it found (hence the name round robin).
But it may or may not choose the fastest one, nor it will do load balancing (if one server goes down).
Still it's poor man's kind of load balancing / some sort of redundancy system.
https://www.cloudflare.com/learning/dns/glossary/round-robin-dns/
With DNS round robin you won't get the situation that the fastest will be the one that always respond. It's just more or less random. HA Proxy, as mentioned, could be a solution, however, you'd have that as a proxy before answering through one of the servers, i.e. that will be your SPOF.
Through DNS is possible but not with every DNS provider. I think Cloudflare can do it, and I know I've once implemented it through a self hosted PowerDNS; that can return answers based on certain parameters/scripts.
Thanks. As far as i can see its not what im searching for cause it should support atleast the fastest responding server. Round robin is ramdomly asking a server (or i have missunderstood something)
This won’t work as you think it should.
(At least it won’t work as long as you are not google, because they are doing IP-Voodoo, that make it happen)
A request to your domain will get one A or AAAA record as answer. Your browser will then use this. So adding more A records will do round-robin from the dns.
There is no native way to query both servers at the same time without a third one, managing this connection.
If „fastest“ means the one that is „closer“ to your request should answer - go looking for geodns-provider. There you can configure country, or even city wise which IP the dns should give your client.
Thanks. I already checked cloudns but i was hoping that there's a free/lowend way to get it done automatically. How is that done with a 3rd server? How is cloudflare or any other big player managing this?
AWS Route53 can be used for latency based routing of A records, but depending on their free tier (if they have one, which I don't know) this probably won't come cheap.
Why this won't come cheap:
if you really want to base the A record routing on latency, the DNS provider would need to constantly probe all latencies for all ISPs towards your different servers. So go figure in terms of effort needed for this.
you can - of course- host your own authorative DNS servers. I do this with the anycast-solution from buyvm.
Your browser will still hit a dns-server but then he will be redirected to a server nearby.
Since the lowend-soltion is dependend on e.g. maxminds geo-database it's not 100% accurate, but ok.
Cloudflare does use something called anycast
-> https://en.wikipedia.org/wiki/Anycast
they more or less tell the internet that they have servers with a special IP that is available at different locations. So you will find the IP in the US east, west, central, east-Europe, central-Europe, Asia, etc.
Since the internet tries to use the "best" connection to an IP it will probably be the one that is closest to you. (the less hops to you requested server the better; though this is not entierly true, but that would be too much detail)
This is used by many companies e.g. google use this for 8.8.8.8 or cloudflare for 1.1.1.1
or akamai or actually any CDN provider out there.
as for the solution with the 3rd server:
it will more or less do the same as the dns servers.
You will first connect to this server- telling him your IP-Adress.
He will then check in it's database what geo-location you are and start a redirect.
e.g.
mydomain.com -> eu.mydomain.com
mydomain.com -> us.mydomain.com
This is probably be the cheapest and easiest solution.
nginx has a module that can help you with this:
https://azole.medium.com/how-to-redirect-visitors-based-on-country-in-nginx-c7c297c915a5
(I didn 't find the article here, so i remember it wrong)
since google is using it's own network it can do even something like IP-spoofing; Meaning the answer that will be sent from google may note necessarily come from the same machine that you requested something. That's even high-level strange, but fast.
If you want to do an actually latency based solution, (that will work to nearly 100%) you really have to check every known ASN (or even Netmask) out there, as OhJohn mentioned periodically, which isn't an easy job on it's own (especially now with a nearly infitie number of ipv6; with lots of "empty" responses).