[Wolves] I'm told that you have a loadbalancing guru among you?
chris-procter at talk21.com
Tue Apr 10 23:29:09 BST 2007
> Gurus is a relative term... on a technical scale
> ranging from Kermit the
> Frog at zero to Linus Torvalds' big brother at ten,
> I'm about a 3-4. The
> scale is, of course, logarithmic :-)
Ah but is it natural, binary or base 10 logs?
> At the moment, I have a server running Apache / PHP5
> and MySQL 5- all works
> well - the PHP code is able to talk to the local
> MySQL server.
> I'm trying to split this out (for resilience rather
> than performance) onto
> four boxes:
> - 2 boxes running MySQL5... this bit I have someone
> who can do
> - 2 boxes running Apache / PHP5, call them WH1 and
> The nature of the application is such that there are
> two classes of users,
> so an obvious way to start is to have "group 1"
> users default to WH1, and
> "group 2" users default to WH2. This gives a bit of
> performance enhancement
> (obviously), but does nothing for the resilience
> I've found various HOWTOs that talk about how I
> could use SIX boxes (2SQL, 2
> Apache, 2 load balancer), but I don't have six boxes
> (nor would I have room
> for them even if I could rustle up some extra kit.)
> What I'd like to be able to do is have WH1 and WH2
> "fail over" onto each
> other in a relatively graceful manner.... WITHOUT
> spending tens of thousands
> of quid on Cisco kit :-)
> I can't believe that this is an unusual requirement,
> so I was kind of hoping
> someone had a HOWTO that pretty much matched my
> needs :-)
The oldest reference I've found to failovers for
computers is from the 1950s, DEC was well into it by
the 1970's. So not really that unusual.
There are several ways of doing this, which one you
use depends on your setup and application.
Firstly have you seen www.linux-ha.org? if not its a
good place to start.
Secondly 6 boxes??? If performance isn't the critical
concern you can do it in 2. Run the webserver on one
box, mysql on the other and have each failover to the
other. Then use another two boxes as a test rig and
spend the rest of the cash on beer :)
On both machines in the cluster you run monitoring
software that at set intervals fires a heartbeat
(think ping) at the other machine if it gets a respnse
then fine, if not it knows its died. When it detects a
failure it starts up the applications that were
running locally and the users carry on using.
The real trick is in the ip address handling. Each box
has its own fixed ip but you also have a third ip
which is added as an alias on the board of the machine
with the running application. Users connect via this
ip (you put it in the dns server) then when the
primary machine fails the secondary just adds the
alias to its own eth0 and (along with the started up
application) bobs your uncle.
For your setup you can do exactly the same but instead
of the backup machine sitting there doing nothing but
monitoring (and active-passive cluster) you can use it
to runn the other app (an active-active cluster)
Take two boxes 10.0.0.1 and 10.0.0.2, setup some
clustering software on both, then configure apache and
mysql on both. Start apache on .1 and mysql on .2 add
10.0.0.3 as the apache floating ip as an alias on .1
and 10.0.0.4 as the mysql floating ip on .2
Make sure the php scripts are configured to talk to
mysql on .4 and the dns server points to .3
Then in the event of a failure of .1 the .2 box
detects it starts up apache, and adds .3 as an alias.
You end up with both apache and mysql running on one
machine, but thats what you have now and its better
then not having anything.
Alternativly you could use four machines, two for an
active-passive apache cluster, two for an
active-passive mysql cluster. In which case you'll
always have them running on sperate machines.
The only remaining trick is to make sure each machine
has the up-to-date data so if the user writes to the
database then theres a failure they after the failover
they'll still have the data. Two possibilities for
this, first shared storage so the datas stored on a
SAN or NAS server they can both access, or you can use
data replication such as drbd (www.drbd.org)
There are lots of other details I could rabbit about
but seeing as I may be way off base here already I'll
give you a chance to explain why I'm missing the point
p.s. and I did all that without mentioning
www.openminds.co.uk who pay me to this sort of thing.
The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html
More information about the Wolves