How a system can be CP?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
In distributed systems, managing data consistency and availability in the presence of network partitions is a critical challenge. The CAP theorem, established by Eric Brewer, provides a framework for understanding these trade-offs. It posits that a distributed system can only simultaneously guarantee two out of the following three properties: Consistency (C), Availability (A), and Partition Tolerance (P). This article explores systems characterized primarily by Consistency and Partition Tolerance (CP).
Understanding CP Systems
CP systems prioritize consistency and partition tolerance over availability. This means that in case of a network partition, these systems will maintain data consistency at the expense of fully servicing all requests.
- Consistency in this context refers to every node in the network agreeing on the most recent state or version of the data. In formal terms, this means the system adheres to linearizability, which ensures that global operations appear instantaneous.
- Partition Tolerance means that the system continues to operate despite arbitrary message loss or failure of part of the system. This is crucial because networks are inherently unreliable and partitions are unavoidable.
In CP systems, when a partition occurs, some parts of the system might become unavailable to ensure no conflicting data is written, thereby maintaining consistency. A famous example of CP systems is Google Spanner. It uses synchronized real-time clocks (TrueTime API) to enforce global constraints on transactions, ensuring linearizability across distributed data.
Examples of CP Systems
- Google Spanner: As mentioned, it uses timestamps to handle global consistency. This is unique, as it combines features typically associated with both SQL (ACID properties) and NoSQL systems (scalability and distribution).
- Apache HBase: Designed for big data, HBase provides consistent reads and writes. If a region server goes down, access to the data managed by that server is temporarily unavailable until recovery occurs, showing preference for consistency over availability.
- MongoDB (with "write concern" set for majority): In this configuration, MongoDB ensures that writes are acknowledged by a majority before they are considered successful, catering to consistency even if it affects availability.
Technical Explanation of CP Operations
Consider a distributed data store consisting of three nodes: Node A, Node B, and Node C. In normal operations, a user's request to write data goes to all three nodes, and it's not considered successful until all nodes acknowledge the write. If a network partition isolates Node C, the system can either:
- Choose to allow operations to continue on Nodes A and B, risking that Node C will have outdated or conflicting data (prioritizing availability).
- Stop the operation on all nodes until Node C can synchronize again, ensuring consistency (CP behavior).
Trade-offs and Considerations
While CP systems ensure data accuracy and consistency, they do so at the cost of availability. During partitions, part of the system may be inaccessible, which could lead to delays in processing user requests. This trade-off must be carefully considered based on the application's requirements for data integrity and user experience.
Summary Table
| Property | Priority in CP Systems | Impact on System Behavior |
| Consistency | High | Ensures all nodes have the same data at all times. |
| Availability | Low | Some parts of the system may be unavailable during partitions. |
| Partition Tolerance | High | System is designed to continue operation albeit potentially at reduced capacity. |
Conclusions
CP systems are ideal for applications where maintaining data correctness and consistency outweighs the need for constant availability. Financial systems, health records management, and other domains where data integrity is paramount benefit from CP configurations. However, for applications where availability is crucial — such as consumer-facing applications that require constant uptime — alternative CA or AP systems might be more appropriate.
Understanding the requirements and limitations of your specific application will guide you toward the appropriate system configuration, be it CP, CA, AP, or a hybrid approach adapting to different scenarios.
Related reading
- How a typical cluster of five servers can tolerate the failure of any two servers?
- How are DDL changes replicated in PostgreSQL
- How are distributed election algorithms implemented in practice (Bully, Ring algorithm)?
- How are distributed queues architectured?
- How are hinted handoffs handled in Dynamo
- How are TCP Connections managed by kafka-clients scala library?
- How big can a MySQL database get before performance starts to degrade
- How CA distributed system according to Cap Theorem can exist

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.