# Poor man's load balancing / geo-based forwarding - Need some hints.



## Amitz (Nov 20, 2013)

Dear all,

I would like to install something that I would call "Poor man's load balancing / geo-based forwarding" and would appreciate your hints.

Here is the idea:

I have a site that has an equal amount of visitors from the EU and America (The continent, not the country). I would like to run 2 VPS with the actual website content. One in the USA (Server A), one in the EU (Server B )

Sync between the two is already up an running, so this is not an issue.

Furthermore, there will be Server C. This server will be a small VPS or cloud instance at Prometeus/iwStack because of the impressive uptime that I have seen with them throughout the last 2 years. Server C will be the A-Entry of the domain in question. In my wildest dreams, Server C will look where the visitor comes from and either forwards him to Server A or Server B, based on the geo-location of the visitor. If Server C cannot geo-locate the visitor, then it will at least try to forward the requests equally to both other servers. All this should happen (if possible) non-transparent to the visitor, meaning that there will be no change in the URL, like us.domain.com or eu.domain.com.

Has anyone of you ever setup something like this and - if yes - would be willing to give me some insight? I am not looking (even though this would surely be nice) for a complete guide. I am willing to read and to learn. So any hint in the right direction is helpful.

Thank you for taking the time & kind regards

Amitz

P.S.: I forgot to mention - I would like to do this without having to pay for out-of-the-box solutions.

Could HAProxy be my solution?

https://www.digitalocean.com/community/articles/how-to-use-haproxy-to-set-up-http-load-balancing-on-an-ubuntu-vps


----------



## drmike (Nov 20, 2013)

Well, depending on the number of lookups a month, you can do this with Rage4's geo-location DNS.

If you are an iwStack customer they offer Rage4 as a freebie benefit of being a customer and that has higher limits/none really.

Obviously, you can go the DNS route yourself and figure out how to make everything work + the geographic functionality.


----------



## ihatetonyy (Nov 20, 2013)

I would go the Rage4 route and throw your iwStack server out of the mix (or add it as a third webserver) -- unless I misunderstand what you're trying to go for, wouldn't the benefits of directing American visitors to an American server be negated by sending them all to iwStack in the EU anyway?

If you're worried that visitors could be directed to a downed server, Rage4 has webhooks for UptimeRobot and the like that allow for a server to be automatically taken out of a rotation if it's down.


----------



## scv (Nov 20, 2013)

Using a proxy server takes away most of the benefit of load balancing and might even cause more issues. You'd be better off with doing GeoDNS yourself - only hard part there is finding (or maintaining) an accurate geolocation DB. This way the visitor's traffic goes directly to the server closest to them without having to take an extra routing step.

The ideal solution is to find a provider that can give you anycast addressing.


----------



## splitice (Nov 20, 2013)

A reverse proxy will most likely give little to no overhead actually, it may even give you better routes if they are optimized (depending on your providers flexibility). There are exceptions where performance would be much greater of course (e.g LEB resources saved by pooling backend connections) but most of them are micro optimizations (shave a few ms).

The main reason to do a GeoDNS'ed proxy performance wise would be for Edge Caching or Edge SSL both of which would give very decent speed improvements.


----------



## TheLinuxBug (Nov 20, 2013)

Hello Amitz,

As stated before using Rage4 for geo-dns is a good solution to this if you wish to use multiple servers.  You really shouldn't need a 3rd server as a proxy as Rage4 DNS will handle the load balancing  based on geo-location. 

Another option may be using a proxy like Varnish/Haproxy in front with load balancing to accelerate loads and the ability to offload your client to multiple servers or depending on the size of your site you may consider an Origin Pull CDN.  Using CDN would allow you to use a single server to provide html content and the base content your site needs, while the CDN can provide quick geo-located access to js/css/images near to your end user.  Most sites especially if using WordPress or and popular CMS should provide plugins for easy use with CDN.  My suggestion would be to use InterNap's CDN services which if you purchase through the right re-seller can be $0.10/GB or less.  Now, this may not help as much with sites highly dependent on MySQL where using two different servers would, but it will accelerate the loading times of the site greatly and at usually a more than reasonable price.  If you are interested in a quote on CDN services or have any other questions about them, let me know and I can try to help you out.  

Cheers!


----------



## Amitz (Nov 21, 2013)

Thank you, Fellows! 

I did not think about the possibility to do this on the DNS level because most services offering this cost some money. I was also not aware of Prometeus offering services with Rage4DNS and will definitely check this out! Sounds as if this is the simplest solution for my "problem".

Again, thank you all & kind regards

Amitz


----------



## drmike (Nov 21, 2013)

Amitz said:


> Thank you, Fellows!
> 
> I did not think about the possibility to do this on the DNS level because most services offering this cost some money. I was also not aware of Prometeus offering services with Rage4DNS and will definitely check this out! Sounds as if this is the simplest solution for my "problem".
> 
> ...


iwStack has free Rage4 as long as you have active account/funds on hand there.   It makes the deposit of funds for iwStack more palatable *if* you use such function and drive traffic via DNS that you are already paying for directly.


----------



## gbshouse (Nov 21, 2013)

Hmmmm I think we will do some magic t-shirts "In Rage4 we trust" soon


----------



## drmike (Nov 21, 2013)

gbshouse said:


> Hmmmm I think we will do some magic t-shirts "In Rage4 we trust" soon


(raises hand for shirt swag)


----------



## rupe (May 1, 2014)

I realize this is an old post, but I was wondering if the Rage4 service was geared mainly towards EU customers or would North American based sites benefit just as much. If it is more EU, then are there any NA equivalents?


----------



## wlanboy (May 1, 2014)

Look at their POP list, they are all around the world.

So everyone would benefit from it - as long as you have a vps in each area too.


----------



## rupe (May 2, 2014)

wlanboy said:


> Look at their POP list, they are all around the world.
> 
> So everyone would benefit from it - as long as you have a vps in each area too.


Signed up, and will test out a couple of 'throwaway' domains I have. Nice that they have a free tier with 250k hits per domain allowed.

They sure do have a lot of configuration options available. Anyone know of a good site/guide explaining some of the options - like DNSSEC, benefits and drawbacks of vanity NS, setting proper SOA records?

Thanks


----------

