W3 Total Cache – Advice needed keeping load balanced servers in sync

I currently have a single web server hosting multiple WordPress sites which use W3TC.

Let’s call said web server “Server A”. I’m looking to clone this server, we’ll call the clone “Server B”.

Read More

I’m then looking to load balance Server A and Server B.

I also want a third “Admin” server. This is where I will log into WordPress and make changes to the sites hosted on Server A and Server B.

Incidentally I have a separate database server, and am using Rackspace Cloud Files CDN for all of my attachments / theme files / etc.

What I’m puzzled about is keeping everything in sync. Or, more specifically, keeping the W3TC cache in sync. For example, if I log in to the Admin Server and publish a new post, due to me having specified that various pages should be purged from cache when I create or edit a post, the page cache on the Admin Server will be cleared. The page caches on Server A and Server B, however, will not be cleared.

I could call a script on Server A and Server B which would use w3tc_pgcache_flush() to flush the caches on these servers, but how do I get these scripts to run when a post is created/edited on the Admin Server? Is there an event I can hook into?

Another option I had considered was that I could use lsyncd to sync any changes to the contents of the /wp-content/w3tc/ folder on the Admin Server to Server A and Server B, but then I realised that no page cache will exist on the Admin Server because no one will ever visit the instances of the sites hosted upon it.

Bonus question: Do I need to sync all of my attachments across all servers or can they reside only on the Admin Server? I ask because W3TC is set to export changed files automatically – if it looks in the /wp-content/uploads/ folder on Server A or Server B and finds it empty, is it going to remove all of my files from the CDN?

I’m hoping someone on here has implemented something similar or knows of a better way of doing what I’m trying to achieve?

Many thanks in anticipation –

chris

Related posts

Leave a Reply

1 comment

  1. It’s possible to segment your WP Admin traffic from other application servers, but that is difficult if you’re not using varnish or some other scheme to redirect requests to a specific application server. I don’t recommend trying to do this kind of thing in general for WordPress at the level at which you currently operate.

    Anyway, for CDN use an origin pull provider and you won’t have to worry about anything you mentioned. Also using memcached as the backend for your page caching will again do away with all of your concerns. You would never want to use a typical network file server for /wp-content/w3tc/ because that simply won’t scale.