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;
- use
rsync
to replicate/synchronize the document root - use MySQL asynchronous replication (not a
NDBCLUSTER
) to synchronize data across the nodes - use
session_mysql
PECL 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.
Thanks Mohanjith,
Load balancing is always challenging and on my projects our teams have to put a lot of time into the design and testing of the solution. Share how you went.
hmm, wonder why you didn’t see https://www.mohanjith.net/blog/2009/04/load-balanced-and-high-availability-cluster-for-your-web-site-under-usd-60-pm-part-2.html . This blog itself is running on a cluster. Bit of a rough edge is fail over. There is still a chance some of the DNS servers will cache the response longer than the TTL, not a big issue with new browsers as they will round robin through the A records before complaining.
Just what I was looking for. Thank you! Bookmark added for sure 😀
hello sir could to tell me how to create a web cluster . Are there any simulating tools for creating web cluster