user1130800
user1130800

Reputation: 99

How to maintain strong consistency in distributed computing?

For example I have Master(M) and Slave1(S1) and Slave2(S2). If I do synchronous replication as below,

  1. Update Master, and lock the write
  2. replicate Slave1 and Slave2
  3. unlock the write of Master.

But the above is not strong consistency.

The users reading Slave1 or Slave2 can get different values at certain moment.

In this case, Master should cancel the write to S1. But users may already read it.


So it's hard to maintain strong consistency. Therefore, what algorithms do companies use to maintain strong consistency if it's necessary? How to make the eventual write value be visible to clients at the exact same time? Thanks.

Upvotes: 4

Views: 5127

Answers (1)

Basit Anwer
Basit Anwer

Reputation: 6860

Putting things in the simplest form;

There are two ways to provide consistency

  • First is to take the lock before writing anything to the database or caching system. This ensures read and write lock. This includes master server as well.

    To further enhance the locking mechanism, the distribution of keys is maintained as such so the reads are always re-directed towards the consistent server(s) (if new servers are also being added at that time).

    At this time of lock, operations can also be buffered (with timeouts) so when the new value is applied. that is returned.

  • Secondly, if replication fails then there is the added complex layer of rollovers. This ensures that data is consistent if not then it is not applied.

Upvotes: 4

Related Questions