QUOTE (webmaster4india)
Does unison or rsync support incremental replication? Will it be able to read files which are in use? Like database files?
Yes. Note that unison and rsync SOLVE DIFFERENT PROBLEMS. Unison lets you modify the data on the replicated side and will try to merge changes made on either side. rsync only replicates one-way -- that is, changes from the receiving side will never be synced to the sending side.
But yeah, both offer incremental replication
QUOTE
Say suppose we sync the file in server a to server b? Will the file be deleted in server b if the file is deleted in server a?
If you want it to, sure. Both tools can be made to do this.
QUOTE
How frequently we can run this? I am planning to implement clustering using this and load balancing provided by EV1. Will this work out? Do you think its suited for shared hosting and shared mail services?
No, this will not work out, at least not the way you think. You can't "replicate" a database this way. Sure, you may copy files, but they have no guarantee of atomicity nor a working merge. You will be left with inconsistent databases on both sides using unison and on the receiving side using rsync. Most decent databases have replication- or clustering-mechanisms of their own for precisely this purpose and reason.
In theory, if your mail system is set up right, this could be used for mailspools, sure. Assuming a maildir-storage-method, there isn't much of a chance for collisions in the filenamespace, so merges of two different emails will not happen.
Shared Hosting might work in simple cases, too. With dynamic programs requiring access to filesystem, you can easily run into non-reconcilable changes if your programmer does not know he is going to be replicated. You can also easily loose consistency (consider the simple example of a simple file-based counter script. Host A and Host B both receive hits that are counted. Both read and write to the file counter.txt whenever the webpage is hit. When you run unison, you will have conflicting changes to that file; when you run rsync from A->B, all counted on B will be lost and overwritten with data from A.
As for frequency : as often as you like, but it will incurr a sizable processing power and storage subsystem hit. A full rsync of a reasonably busy webhosting machine to another will take minutes or even an hour, EVEN if there were no actual changes (this is due to the fact that rsync would have to look at every file and whether it has changed ... This is a lot of work). Remaining services on your server will slow down considerably during this period.
If you want two hosts to access the exact same files, you'll need a distributed filesystem (like Coda), or a fileserver exporting its filesystems via a networked filesystem (like NFS) (and even in this case, you can't expect two instances of a database to share the same files without it blowing up in your face).
Good luck with your endeavor