Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm currently managing a cluster of PHP-FPM servers, all of which tend to get out of sync with each other. The application that I'm using on top of the app servers (Magento) allows for admins to modify various files on the system, but now that the site is in a clustered set up modifying a file only modifies it on a single instance (on one of the app servers) of the various machines in the cluster.

Is there an open-source application for Linux that may allow me to keep all of these servers in sync? I have no problem with creating a small VM instance that can listen for changes from machines to sync. In theory, the perfect application would have small clients that run on each machine to be synced, which would talk to the master server which would then decide how/what to sync from each machine.

I have already examined the possibilities of running a centralized file server, but unfortunately my app servers are spread out between EC2 and physical machines, which makes this unfeasible. As there are multiple app servers (some of which are dynamically created depending on the load of the site), simply setting up a rsync cron job is not efficient as the cron job would have to be modified on each machine to send files to every other machine in the cluster, and that would just be a whole bunch of unnecessary data transfers/ssh connections.

share|improve this question

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

3  
Use a git repository. –  Michael Hampton Dec 11 '12 at 18:19
1  
What about an NFS server? –  mdpc Dec 11 '12 at 18:23
1  
For a git repository, I'm looking more for something that will immediately change the all of the linked systems once a change happens. -- As for an NFS server, as the machines are hosted on different subnets (and different regions of the country), the latency between them is too great. –  GForceSys Dec 11 '12 at 18:31
    
NFS should work fine on different subnets, but the latency might be a problem. NFSv4 offers good NFS over TCP, which can help on WANs. However, I completely understand your concerns. We find that NFS over a high-quality WAN will still have problems, and NFS over the Internet would have even more issues. –  Stefan Lasiewski Dec 11 '12 at 19:09
    
How many servers are in your cluster? –  Stefan Lasiewski Dec 11 '12 at 19:10
show 3 more comments

3 Answers

You may want to consider using Puppet or CFEngine to make changes to the servers. Tools like these allow you make controlled changes to all servers. They help a lot keeping the configuration of multiple servers in sync.

share|improve this answer
add comment

Take a look at GlusterFS. AFAIK it is available on EC2.

It's replication/mirroring is file-based, and it is quite easy to setup. Files reside in local directories on local filesystems of the nodes.

Specifically in your case you can setup mirror between all app servers and safely access this local directory for reading to work around FUSE overhead (but you have to write via glusterfs mount, so files are replicated on all nodes).

share|improve this answer
    
Isn't GlusterFS basically a networked file system? I'm afraid of using networked file systems because of the ridiculous throughput they put on the systems. Given this, I'm looking for something more like Dropbox, where only selective files get synced and each request does not have to load files over the network. –  GForceSys Dec 11 '12 at 18:37
1  
You might want to at least test out this solution. It looks like the easiest and most reliable solution. You can always stop using it if it eats up too much throughput. –  aglassman Dec 11 '12 at 18:57
    
GlusterFS is more about distributed than networked filesystem. For your case - i bet it worth trying. You can setup mirror on all your servers and it will sync files, not block devices. –  Sergej Alikov Dec 11 '12 at 19:45
1  
Main drawback - it is FUSE filesystem, so performance penalty applies. But in your case, you can use the trick - access files on the nodes directly for read(no penalty), and write to them via glusterfs mountpoint. –  Sergej Alikov Dec 11 '12 at 19:47
    
@SergejAlikov welcome to Stack Overflow and thanks for answering. Please expand your answer a bit and let us know how it could help answer the question. Please read the notification box above which says We're looking for long answers that provide some explanation and context. Don't just give a one-line answer: please explain why you're recommending it as a solution. Answers that don't explain anything will be deleted. See Good Subjective, Bad Subjective for more information. –  Stefan Lasiewski Dec 11 '12 at 22:45
show 2 more comments

Being extremely familiar, I'm unaware of any Magneto installation that makes changes to files or directories through normal use other than

./var/cache   <-- should be on a distributed cache like Redis or Memcache
./var/report  <-- doesn't need to be network replicated
./var/log     <-- doesn't need to be network replicated
./var/locks   <-- the admin node should operate on a single server
./var/session <-- should be on a distributed cache like Redis or Memcache
./media/catalog/product/cache <-- doesn't need to be network replicated

In any case, a network file system like NFS wouldn't be a solid choice - unless you've got vast experience securing and tuning it over WAN.

Network block replication, eg. Gluster/DRBD would also not be a good choice. Performance is weak for Gluster (and complex to configure) and DRBD would have to use a multi-master filesystem like OCFS2 - not ideal.

Newer releases of Magento also support DB storage for media, for this exact reason - although this is beyond less than ideal and is merely Not A Good Idea.

Version control software (Git/SVN) would take care of your code-level requirements. You could easily add a hook to your staging machine to perform a touch-less multiple pull on the production systems. But wouldn't cater for admin uploads (images etc.).

It would make FAR more practical sense to merely redirect all your admin traffic and production roll-outs to a single node - then replicate from that source to your remaining nodes.

Lipsync is an application that would cater for your "Dropbox style" demands and perform changes and and when necessary. We've used it with Magento clusters on a number of occasions.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.