In this post I’m gonna explain you how to deploy really fast and cheap cluster of Linux Containers. I use the same setup in a production enviroment for a big accounting software (10GB++ of MySQL).
Why LXC? Because it is Über-cool! Compared to the Hardware Virtualization, the runtime performance is near the bare metal speeds. Operations like starting/stopping of the system or clonning and snapshots are really fast. There’s no virtual BIOS, boot loader and kernel. A given number of containers can share the same system resources as they are installed on the same bare metal system and are still isolated. It’s really lightweight and flexible. You can containerize everything - a whole system or a single application. Stéphane Graber has a really good blog post series about LXC.
DRBD will provide the block device replication between the servers. Let’s think of it as a RAID1 array between the two machines. It can work as master-master or master-slave. The master-master setup is more risky and it works only with shared cluster file systems (GFS, OCFS2 or GlusterFS). I don’t have the balls to use it master-master on two nodes for VM’s and containers, so in this setup I’ll use master-slave. The difference is that when an array is promoted as slave on a given machine, it cannot be accessed.
Btrfs is the new hipster in town :) It’s a new “copy on write” file system and logical volume manager for the Linux kernel. It has many similarities with the ZFS, but is part of the kernel. Snapshotting and cloning of the containers are easier with Btrfs. It can make snapshots and subvolumes of a given directory and mount it as another block device. Note that it’s already stable but still has problems. Stable filesystem for production environment must be 7+ years old! I bet on the backups :)
So, let’s suppose that we have two identical machines with this sample configuration:
- Intel Xeon E5;
- 16GB of RAM;
- 500GB RAID1 array -> /dev/sda;
- 2x 1TB RAID10 arrays -> /dev/sdb and /dev/sdc;
- Standart gigabit interface/s -> eth0;
- 10GB Ethernet interface, linked between the machines -> eth1;