4

My understanding is that in a multi-master DB architecture:

  • You have 2+ DB servers, both acting as read/write masters; and
  • It either up to some type of load balancer to balance operations across these multiple masters; and
  • Whenever a server gets a read, it fetches and returns the queried data locally; and
  • Whenever a server gets a write, it writes + commits locally but then replicates that write in real-time to the other servers (this is why the system implicitly requires a load balancer, to prevent the same write from going to 2+ different masters at the same time); and
  • You can have Active/Active or Active/Passive setups. With the former, the load balancer truly balances writes across all nodes. I don't really understand the latter (Active/Passive)

So to begin with, if anything I have stated above is incorrect, please begin by correcting me or clarifying it for me! Assuming I'm more or less on target:

Then what is (really) the difference between Multi-Master and Peer-To-Peer (P2P)? In a P2P system, any read gets executed and returned locally, and any write gets written locally and then replicated out to all the peers...so aren't they one in the same?!

smeeb
  • 27,777
  • 57
  • 250
  • 447

2 Answers2

2

Master Slave

  • Only Master can take writes.
  • Slaves asynchronously replicate from Master and serve only read queries.
  • For prevention against data loss, a commit can be marked as completed when atleast n slaves have also written it along with the master.
  • MySql

Master - Master Or Multi Master

  • Any of the server can take Reads/Writes.
  • All of the servers replicate synchronously. So the data is always consistent.
  • Can be configured for asynchronous replication but then it becomes similar to Peer to Peer architecture
  • Has split-brain problem with only two masters. Can be resolved with having at least 3 masters.
  • CouchDB

Peer to Peer

  • All servers can take both Reads/Writes.
  • Asynchronous replication between servers, so Reads can be different. (Eventual consistency)
  • Cassandra, ElasticSearch

Leader Follower

  • Only the leader serves Reads/Writes.
  • Followers only replicate asynchronously.
  • Can be configured for N followers to replicate syncronously to prevent data loss in case the leader goes down.
  • Kafka
  • 1
    CouchDB falls under both multi master and peer to peer, multi master is more toward its cluster (https://docs.couchdb.org/en/stable/cluster/index.html) functionality while peer to peer is more of its replication (https://docs.couchdb.org/en/stable/replication/index.html) functionality – Howard Lince III Jul 04 '20 at 23:55
1

They may seem similar but there are subtle differences, hope this helps:

In Active/Active writes can go to any server and are then cascaded to other servers in the cluster.

In Active/Passive reads will only ever go to a single node in the cluster and then be cascaded to other nodes.

Depending on the technology and implementation in both scenarios reads may be serviced by any of the nodes within the cluster.

Rob Stone
  • 204
  • 2
  • 4