emilly
emilly

Reputation: 10530

CAP theorum is applicale for Replication or Sharding?

I went through CAP . After going though it, my understanding is CAP makes sense only in context of replication (where write happens on one node i.e. Master and then replicated across slaves) not for sharding/horizontal scaling(where data is partitioned based on some key. So different data lies on different nodes).

Ideally data will be always be consistent/available in shards(mainly NoSql DB) as single node contains required data and there is no need to write the same data to other node. So in NoSql there is no need to be parttion tolerant as there is node of communication between node until and unless replication is required. So why CAP theorum comes into picture for NoSql DB where sharding is used not replication.

To me choosing b/w C and A should makes sense where we are using replication not shard which mainly happens in SQL DB not in NOSql DB but reading the articles on google primarily talks about NoSql DB's in terms of CAP

I know I am missing something as CAP theorum but not sure what it is ?

Upvotes: 1

Views: 1541

Answers (1)

Enrique Molinari
Enrique Molinari

Reputation: 317

It is true that CAP theorem does not apply if there is only a single master for each shard (without any type of replication). But most implementations have a master shard plus one, two or more slaves for read only queries. And this configuration repeats for each shard in the cluster. Then, there is replication hence CAP theorem applies (and PACELC theorem applies). The replication can be for scaling the shard but mostly for availaibility. If the master shard fails, one of the other takes the master role.

Upvotes: 2

Related Questions