2 ms·
When you enable replication in MongoDB, you turn on an effectively global lock: the 'local' db must be locked for all primary writes so that the oplog can be wr
by reubenbond 13y ago
When you enable replication in MongoDB, you turn on an effectively global lock: the 'local' db must be locked for all primary writes so that the oplog can be written consistently. MongoDB replication is a very unfortunate thing, IMO. Primaries write to the target DB (maybe a cheap atomic increment) and write the query itself to the local database (taking that global lock). The secondaries use tailable cursors over that oplog and apply the operations to their own target db and local db (for fail over). So basically you have global locks and replicate via disk io. This slaughters performance on cloud services. A smarter approach might be to use distributed consensus like Paxos or Raft and avoid disk. Because they use that oplog for replication, durable writes are bottlenecked by disk io and have a terrible concurrency factor. Anyone please feel free to correct me on any of that