CAP Theorem

Introduction

C.A.P. stands for Consistency, Availability, and Partition tolerance. C.A.P theorem describes system guarantees with regards to its data.

(C)onsistency guarantees the ability of a system to return the same data or results. Data always returns the same result or an error; if data updates it always returns the updated value.

(A)vailability guarantees every system request returns a response. The data may return different data from different writes to the system.

(P)artition tolerance refers to the number of delayed or dropped requests a system experiences as a whole. Despite this, the system will always operate.

Why is CAP Theorem important?

Regardless of the size, a system will eventually experience partition failure. Why? Because System hardware fails, software errors affect servers, natural disasters destroy infrastructure. The overall system must plan for such failures during their design. As a result, the system must either choose consistently or availability.

If a system chooses Availability any actions will execute and return a value. During an update event, however, the system will not guarantee data updates immediately. This could result in inconsistent data for the end client.

If the system chooses Consistency a READ request will return the same value. During data updates however the end-user may not access the system, after settling data updates the new data will always return regardless of the caller.

When to choose Consistency or availability

Whether to choose availability or consistency depends on the data and the business. For example, a bank must enforce consistency because reporting different monetary values in their data will cause way more issues than guaranteeing availability to the end-user. A social media company on the other hand could deal with inconsistency since delayed data won't affect the experience of the end-users expectations.

Conclusion

Data constraints and business needs determine a system's availability and consistency constraints. Your system's requirements will determine your C.A.P. requirements when designing your system.

In practice, many consistent systems experience little downtime and still guarantee a high level of availability. Systems choosing availability can eventually ensure consistency and in many circumstances accomplish this quickly. Regardless C.A.P. theorem always dictates a system's design without exception.

Introduction
CDN