Dual web servers that load balance and point to the same database

1

So I am currently running a web server at my house with a Raspberry Pi. Quite successfully might I add. The only problem is that sometimes the SD card becomes corrupt and my site goes down for an hour or so while I re-image it. I have a nightly backup so its not big deal but I don't want my site to go down at all.

So my solution is that I already have a second pi, why not make dual servers.

The shared database I think I can figure out on my own. The problem I am running into is that I have no idea how to load balance or even direct traffic to multiple servers. Do I need a machine in between my router and servers to direct traffic?

Here is my current setup

enter image description here

And this is what I want

enter image description here

Does it look like I have the correct idea on how to architect this? What am I missing?

Anthony Russell

Posted 2014-02-04T00:00:36.510

Reputation: 180

Answers

1

Load balancers come in all shapes, sizes and costs. If you want to do it for free, Linux-HA works quite well, although it has a bit of a learning curve. You could even do it with iptables, or as a Round-Robin DNS entry, although these last two have no monitoring or facility for dealing with malfunctioning machines.

There are also many appliances and software which provide this functionality.

The general idea is that there is a single machine (or appliance) which replies to the requests, then forwards the requests on to two or more servers behind it (sometimes in NAT, sometimes not), though the load balancer will always masquerade the public IP. Round Robin DNS falls outside this, as you set up an equally balanced DNS record for the domain name, and the DNS server will give out IP 1, then IP 2, 1, 2, 1, 2, etc.. in this case there is no machine masquerading the public IP.. and of course, there is no facility for detecting and mitigating unavailable machines.

More advanced software and systems keep track of the number of connections, the health of the servers behind, and can do things like ensuring that https (or session) connections always go to the same server, to avoid issues with connectivity. These machines will make sure one server is not overloaded, and if it becomes unavailable, it will take it out of the pool of addresses it forwards requests to..

Hopefully this gives you something to start with.

NickW

Posted 2014-02-04T00:00:36.510

Reputation: 1 029