AWS – How to Synchronize EC2 Instances

amazon ec2amazon s3

I have been looking for a way to synchronize files between my EC2 web servers .
However in most of the places it is mentioned that S3 can be used in such cases . However my question is S3 provides for only static web hosting , whereas i have php files on my web servers . So how do i synchronize them ?

Best Answer

The simplest solution would probably to periodically run rsync to sync the changes on one host to another. There are also bidirectional tools similar to rsync, such as Unison. You could use lsyncd to monitor the filesystem, which starts Unison to then perform a sync. Here's a tutorial.

Another popular and simple way is to have a file server where you store your PHP files. These directories are shared via NFS and mounted by the actual webservers. This file server doesn't have to be powerful. With caching the file system performance is usually pretty good. Synchronisation is of course not instant, though quite good. It's usually good enough for a webserver and easy to set up.

Other more complex options are distributed file systems and related systems, such as GFS, GlusterFS, DRBD. I'll leave it to yourself to investigate these, but they're considered quite complex. They sync almost real-time but can be hard to set up and troubleshoot.

Related Topic