Syncing multiple wordpress web servers in a farm

We've used Super Flexible File Synchronizer for stuff like this in the past. It works really well and has a number of options to control syncing.


I'm not a wizard with IIS, but hopefully the technique will translate over.

I'm presuming that there's a shared hostname that is load balanced between the two servers, and that there is also a publically accessible name for each.

What you want is a conditional redirect on one of the two servers combined with some kind of file sync. If the URI starts with /wp-content and the file exists, serve it locally. Otherwise redirect to the other server. Server A redirects to B and vice-versa.

This should result in a seamless experience for viewers - they'll just get a temporary redirect for images in the window between the post going up and the sync running. Depending on bandwidth or redundancy concerns, your sync interval could be much longer than 15 minutes, since the site should render properly the moment the post goes up.

In nginx, I'd do this with a block like so:

location ~ ^/wp-content {
  if( -f $request_filename ) {
    expires max;
    break;
  }
  rewrite ^/(.+)$ http://otherserver.com/$1 last;
}

nginx is available for Windows, but I doubt you want to switch web server software to do this. Hopefully the idea can be converted over to IIS or whichever software you're using.


I'm putting this as a separate answer because it's a different approach:

What about putting the images in cloud storage (Amazon S3 or similar), then having your users use links to the cloud. The bandwidth costs might be a bit higher and there are possibly training issues getting users to upload to the cloud first, but it eliminates the need for local filesystem or cross-servers checks.

It also should scale regardless of the number of servers you deploy.