Understanding the CAP Theorem

CAP theorem

When your database has a single node, and that node goes down due to issues like network or hardware failure, application downtime will increase until the node is restored. In another scenario, you might even lose your data.

Partition tolerance is required in modern distributed systems.

This problem can be solved by using a multi-node system. In particular, the CAP theorem implies that in the presence of a network partition, one has to choose between consistency and availability.

Note: Some databases, like Oracle, do not natively support P (network partitioning). However, you can achieve partitioning using third-party tools like Shareplex.

You chose Consistency

Consistency refers to the requirement that at any point in time, all nodes should have the same data. In this case, no node will have an inconsistent state compared to other nodes.

Whenever a write happens, the node needs time to update all other nodes. Consequently, the node may be busy and unavailable on the network while processing these updates.

However, this ensures that all nodes see the same data at the same time.

Example: In a transactional system, consistency is very important. Even if one node is lost, other nodes should not show outdated data.

You chose Availability

Availability refers to the requirement that at any point in time, every node should be 100% operational.

Whenever a read or write happens, the system ensures the server will always be available. However, this doesn’t guarantee that data in other parts of the network is 100% replicated at that exact moment. It will be eventually replicated.

Example: In a log management server, you might be okay with minor data loss, but you must ensure the log server is always available when a client wants to log data.