简体   繁体   中英

Elixir/Phoenix geographical load balancer

I'am trying to make a geographical load balancer with elixir/phoenix, so that when clients initially connect, it will pick the closest (least ping/latency) server and use that one for the future connections.

Let's say the client reaches balancer at get "/balance", PageController, :index , and in my db I have 2 servers: server1.domain.com and server2.domain.com . Is it possible to pass somehow the connection (or ping) from client to both servers with elixir back-end?

I can probably make logic in front-end, pinging with js and then returning values to the back-end for storage. However, I would rather have everything in back-end.

Any tips or advice regarding load-balancing appreciated, as I am not 100% sure if that's the proper way of doing it. Thanks!

Well, if you just have 1 load balancer, it doesn't make much sense. For example, your load balancer is in the US and you have an application server in the US and in Europe. When a visitor from Europe visits your site, he will first hit the load balancer in US which then connects to the application server in Europe (or even the US, it doesn't matter). You gain no speed from it.

You need to do the geographical routing on the DNS level I guess so the visitor hits the nearest server to him directly (which can be a load balancer or application server).

I haven't dug into the topic yet but a good starting point would be to google for geographical DNS load balancing and see where it gets you.

Maybe someone more experienced with this topic can give a more detailed answer on the technical side but maybe you also find what you need from the suggested Google search.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM