Update 2009-09-02: Now I’m using a single Linode and a Xen VPS from my very own hosting service. This means the VPSes have one more thing less in common, hosting company.
Until recently I used one Linode VPS for hosting all my sites. On 26th March, there was a DDoS attack on one of the Linode customers in the Fremont Datacenter (where my node was as well). This made my sites inaccessible for couple of hours. This got me thinking, what could be done to mitigate such downtime. Answer of course is having a load balanced and high availability cluster. However I couldn’t afford 2 dedicated servers to do this, but I of course can afford 2 Linodes 🙂 . I’ll try to explain how I set up a load balanced, high availability and shared nothing cluster using Linodes (you can use any VPS or dedicated server). I used two Linode 540 s for the job.
All of my web sites are either using PHP, Python or Perl. All of them are using MySQL as the database. Problems I had to solve were;
- replicate files across the nodes
- replicate databases across the nodes
- replicate session (PHP session variables) across the nodes
All the replication needs to be done securely, so I went for a SSH tunnel between the nodes of the cluster. Over which I’ll;
rsyncto replicate/synchronize the document root
- use MySQL asynchronous replication (not a
NDBCLUSTER) to synchronize data across the nodes
session_mysqlPECL extension to store PHP session in MySQL database transparent to all applications
Check back next week when I’ll post with configuration examples on how I configured my server. If you are in a hurry above pointers are good enough to get you started.