Sync vs Replication


These terms describe how data is kept consistent across different locations or servers.

Sync (Synchronization)

  • Definition: Syncing refers to making data identical between two or more locations. Typically, synchronization tools only copy changes (deltas) and keep both locations in sync either in real-time or at scheduled intervals.
  • Types of Sync:
    • One-Way Sync: Data flows from a source to a destination, but changes in the destination are not synced back to the source (e.g., rsync or Lsyncd in one-way mode).
    • Two-Way Sync: Data flows both ways. Changes made on any server are synced to the others (e.g., Unison or Syncthing).
  • Example Tools:
    • rsync: One-way sync, used for copying files from one server to another.
    • Unison: Two-way sync, where changes on both servers are reconciled.
    • Syncthing: Two-way sync, focused on real-time file synchronization.
  • Use Case: You would use synchronization when you want to ensure that files are identical across two or more systems but not necessarily in real-time (e.g., syncing website files between development and production environments).

Replication

  • Definition: Replication involves keeping copies of data across multiple locations, often for redundancy, availability, and fault tolerance. Replication generally happens in real-time and ensures that if one node fails, the data is still available from another node.
  • Types of Replication:
    • Synchronous Replication: Ensures that changes are immediately reflected on all replicas (real-time replication). If one server fails to replicate, the operation doesn’t complete (used in high-availability systems).
    • Asynchronous Replication: Changes are made on the primary server and then copied to the secondary servers at intervals or with some delay.
  • Use Case: Replication is commonly used in databases (e.g., MySQL replication), distributed file systems (e.g., GlusterFS, Ceph), or object storage systems (e.g., Amazon S3 replicating objects across multiple data centers).
  • Replication Examples:
    • GlusterFS: File-level real-time replication.
    • MySQL/MariaDB Replication: Database-level replication, typically synchronous or semi-synchronous.
    • Ceph: Object, block, and file storage replication.