Load balanced and High Availability cluster for your web site under USD 60 pm

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;

  1. replicate files across the nodes
  2. replicate databases across the nodes
  3. 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;

  1. use rsync to replicate/synchronize the document root
  2. use MySQL asynchronous replication (not a NDBCLUSTER) to synchronize data across the nodes
  3. 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.

How to customize Web Invoice e-mail templates

In the latest release of Web Invoice – Invoicing and Billing for WordPress plugin you can customize the e-mails sent to your clients. You can customize the subject as well as the e-mail content. Please bear in mind that Web Invoice only supports plain text e-mails, but you can do wonders with plain text ๐Ÿ™‚ .ย  This can definitely come in handy if you want to localize your invoices or just does not like what comes as default.

Now to get to the point, the e-mail templates are found in ‘Web Invoice’ -> ‘E-mail templates’.ย  There are three templates,

  • Invoice e-mail – First e-mail your client receives about the invoice
  • Reminder e-mail – E-mail sent when send reminder(s) is selected
  • Receipt e-mail – Sent when the client makes a payment. You also need to set ‘Send Payment Confirmation’ to yes in Settings

All variables are of the format %variable_name. Bellow you will find the list of variables available in the current version.

  • %call_sign – First name + Last name of the client
  • %business_name – Business name as set in the ‘Settings’
  • %recurring – Recurring or not
  • %amount – Amount, with currency symbol and currency formatted
  • %link – Link to the invoice
  • %business_email – Business e-mail as set in the ‘Settings’
  • %subject – Invoice subject
  • %description – Invoice description

You can definitely use the default templates as a guideline for your templates. IMHO, default templaes are awesome ๐Ÿ˜‰

Don’t go away, there is more. You can write your own plugin to add more variables. e.g. you want to use web invoice along with a booking system. In your plugin add a filter for web_invoice_email_variables and add to the global array (variable) $web_invoices_email_variables.

I want to hear what you think about this feature or Web Invoice in general. Please post your ideas and comments in the Web Invoice community forum. Do not forget to subscribe to my RSS feed to get latest news about WordPress plugins and all things web ๐Ÿ™‚

Read only Facebook – Database write failed

To my despair Facebook went read only for a brief period of time (aproximately 10 minutes). I was not able to comment on my friend’s status messages, or like them, or post my own status message; I was confronted with the message bellow. However adding friends, approving requests were working fine. I believe the issue was isolated to status messages and related functionality (IMHO most popular).

facebook-home_1235722315186

Facebook do not dare to do something like this again, I need Facebook to keep in touch with my friends. I’m not a Facebook addict, just that the issue happened to coincide with the time of day I would get on Facebook to get an update on my friends andmake my own online presence.

I would like to know whether you had a similar issue, or was it just me. At the time of writing the issue is fixed. Thanks Facebook for the quick fix.