Apologies in advance for being a total newbie with all things infrastructure related.

A little background: I'm developing a server app for an Android application. The app will communicate with the backend using its domain name (for instance, JSON POST example.com/doSomething). The server code is currently running behind nginx on one machine and everything works fine.

I only have 1 external IP address (which is where example.com is directed to).

However, I have 2 Linux servers at my disposal which I would like to use to host the server. They will host identical binaries and have access to the same database, etc. and will behave identically in all respects. I would like to use both servers so that I can have (1) redundancy and (2) performance optimization (round robin) if possible instead of the current setup which is 1 server behind my domain.

The question is: Is it possible to somehow configure nginx (or anything else really, even the DNS server) so that requests to example.com automatically are redirected to one of the two servers, whilst maintaining a round robin structure, so that both servers serve the same number of requests and if one server goes down, the requests still get sent to the second server?

If it's possible, how would I go about it and if not, do you know of any other way to make use of both servers?

Many thanks in advance,


You could do it with nginx, but I'd recommend haproxy to do your loadbalancing.

You will want to run it on both your nodes, with a floating IP to implement redundancy for your load balancing service (i.e., make sure that the loadbalancer doesn't become your Single Point of Failure).

| improve this answer | |
  • Thank you very much Felix. I have to use nginx for my use-case because of the limitation of the underlying framework I'm using (and my lack of understanding of other technologies doing this). With regards to "floating IP" or KeepAlived link you pasted, I had a quick look and it looks to be exactly what I need. One question though, does the Virtual host live as a daemon on BOTH servers? If not (i.e. it only runs on one server), how would it prevent the single point of failure issue? Wouldn't it become a SPOF itself? – kha Jul 16 '14 at 15:28
  • Note that you can operate haproxy as a proxy in front of nginx. That's my recommendation. - What do you mean by "virtual host"? – Felix Frank Jul 16 '14 at 15:33
  • I looked at keepalived.org/pdf/UserGuide.pdf and there, it mentions an "LVS Router" (or a Linux Virtual Server) which I referred to as Virtual Host (my bad). It's a daemon process that I need to run apparently to activate the KeppAlived to assign virtual IPS to my nodes. That's what I was referring to. I'll definitely look at the haproxy on nginx tonight. – kha Jul 16 '14 at 15:38
  • Keepalived runs on each node to make them a redundant pair. For your use case, the VRRP support would suffice, no need to go for LVS. – Felix Frank Jul 16 '14 at 15:40
  • Thank you very much. I will have a look at these soon. Marked as answer. – kha Jul 16 '14 at 15:46

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.