Best practice for load balancing and virtualisation

load balancingpfsensevmware-esxi

I made some searches here and didn't find anything relevant enough for me. I'll try to be as brief as I can.

I currently have OSX servers, three of them. I am moving to a virtualisation enviroment for redundancy and since Apple has cancelled the Xserve. I have no prior experience with virtualisation, but I'm a quick learner and I have administered servers since 1997.

So, new dedicated server in new data center. Kickass hardware, installed VMware ESXi and inside that, I've created two networks, "VM Network" and "Switch". "VM Network" is connected to the physical NIC and "Switch" is a virtual switch.

Then I created a VPS named "FW" that has two virtual NIC's, one to each network in VMware, installed pfSense on this virtual machine and bridged the "real" NIC with the internal Switch. Done.

Then I intend to create my resource pool on the "Switch" network and let pfSense load balance it.

My Web application is currently contained in a single directory that weighs in at approx 300GB of data, my database is about 50GB more. They are currently on Xserve 1 and Xserve 2.

My current thought process has me at these VPS machines:

1. Main server (10.0.0.10)
This contains two virtual hard drives, one small for Linux and one large for my web application. The larger is mounted inside Linux as "/Atlas" (name of my CMS) and is then NFS exported. VPS has 2GB of RAM and 2 CPU's

2. Database server (10.0.0.11)
This is the master database server

3. Web servers (10.0.0.20 – 10.0.0.30)
Ten Linux servers, each with 5GB of HD, 5GB of RAM and 4 CPU's. Each mount the NFS export from #1 and can read and write to my Atlas.

My questions are:

  1. Should I run MySQL slaves on each Web server in 3? I only have about ~900GB in the server, so space is a concern.

  2. If not, should I have seperate MySQL slave failover servers in the same VMware, in case something happens with #2?

  3. I will rsync-backup the Main server to an offsite location, but is there a better way than NFS to let every web server read and write to this data. Using a cluster filesystem would lead to space concerns, rigth?

  4. Should I use a VPS for load balancing and use Apache's own LB? Is that better for a web application than using pfSense's LB?

  5. Any other weak points in my thoughts here? I will use this as my main server, but I will have a failover server set up identically in another location and use DNS servers to reroute the traffic when needed (either automatically or manually).

I'm not building the Fort Knox here, but I need better redundancy than I have today, and I want to do it as "correct" as possible. Any help/comments are greatly appriciated!

Best Answer

  1. A multi-tier network topology means you should never run MySQL on your web server. If you need redundant or load balanced MySQL servers, then create db1, db2, db3, etc. Don't create more slaves then you really need, since replication is an all or nothing deal with standard MySQL.
  2. What I normally do is MASTER-MASTER replication. This is normally not recommended due to key conflict risks, but I wrote some scripts that the secondary server runs in read_only mode to avoid writes. So if a server dies, it is easy to flip the read_only switch and start accepting writes.
  3. NFS is fine; just do the usual performance tuning and testing.
  4. Take a look at haproxy for doing Apache/HTTP and TCP load balancing. Works great with MySQL even.. You can run haproxy in a VM.
  5. Having redundant VMs is great but running on a single physical machine is still a weak point. Having 10 identical Linux VMs competing for resources could also be a weak point.

Final comment: ESXi is great (don't get me wrong) but I would not use it in this situation. Take a look at a containerization system like OpenVZ. Proxmox provides a great user interface to it. Performance will be significantly better; each VM can use all the RAM and CPU cores. (Unless you restrict it of course.). OpenVZ only works with Linux of course. But any webapp that works on Xserve should work in a Linux container as well?

Related Topic