Mirrored dynamic sites using WordPress

July 23rd, 2006

When synchronizing content across two or more servers one of the trickier aspects is handling user updates – forum posts, comments etc. If updates are accepted on all servers then merging the data would be a regular headache.

Instead, ClonePanel requires that each server be given a role – slave or master – and updates made on the master are copied to the slave. If any changes were made on the slave they would be overwritten and lost at the next sync. So it’s essential that the master server should handle all user updates and the slave must always be read-only.

WordPress handles this perfectly through the two setup options: WordPress address and Blog address.

The blog address is used throughout the site for links to posts, categories and pages – this can be blank to ensure that a visitor browsing the site (master or slave) will stay on the same site / server he first arrived at.

The WordPress address is used in links to admin functions (Register, Login, Dashboard) and in the action of forms – all the things that change the site in any way. So here we use the fully-qualified uri of the master server and ensure that all changes are made only there.

This site itself is an example. It’s available at clonepanel.com and clonepanel.net – one hosted in Australia the other in California (you may notice a slight speed difference, depending on your own location). You can browse either site without problems but as soon as you try to register, log-on or leave a comment you will find yourself on clonepanel.com – the master server.

The next step is to introduce failover – if the master server goes offline, how can the slave take over? That’s more difficult, and will be the subject of many future posts…