Circular RSync for Wordpress

1

I've got 4 servers in a load-balancing setup. And I've got a wordpress app on which I need to upload images. Now there is rsync set up on all the servers on a cron with a 1 minute interval with the options

rsync -rav --delete

Consider the 4 servers as Server A, B, C, D. Lets say that the image is uploaded on Server B. Now if the cron on Server A is fired it'll delete the images on Server B, when the intent was to copy the images from Server B to C, C to D and finally D to A. How can I have such a setup?

Batman

Posted 2013-05-20T11:30:12.103

Reputation: 113

Any particular reason you don't have one 'master' that isn't synced to? – Daniel Beck – 2013-05-20T11:34:32.000

That's because the upload can come from an external user who is not aware of the existence of the 4 servers, so the uploaded image can come to any of them. – Batman – 2013-05-20T11:36:52.187

Why aren't you uploading to the master? – Ignacio Vazquez-Abrams – 2013-05-20T11:40:09.417

The upload is done through the Wordpress UI which can send it to any of the servers, which the browser is bound to at that instant – Batman – 2013-05-20T11:45:04.523

I think what @DanielBeck meant was that you have one server which you sync everything to, then you sync everything from that server to each of the other three. That way the only server that does --delete is the one that is supposed to have the combined view. – a CVn – 2013-05-20T12:15:03.283

Answers

0

Instead of using a rsync schedule, if you're under GNU/Linux, you can create a thin inotify wrapper to watch for changed files on all servers so that you can sync only what's needed. You'll save tons of useless I/O and avoid the need for a “master” server.

Patrice Levesque

Posted 2013-05-20T11:30:12.103

Reputation: 780

0

Since rsync and Wordpress upload are two decoupled processes I would sugest to use a fifth server (or one of the 4) to upload the images on and then either calling the images from that remote server or rsync the images locally.

Check this post regarding uploading images on a remote server from a wordpress app:

https://wordpress.stackexchange.com/questions/74180/upload-images-to-remote-server

Anyway, the advantage of using a dedicated remote server(s; for redundancy) is that you have immediately access to those images, without waiting for rsync.

Mihai

Posted 2013-05-20T11:30:12.103

Reputation: 156