Explore key concepts and real-world scenarios involving the trade-offs between Consistency and Availability in distributed systems. This quiz helps you understand how to select CP or AP systems based on design priorities, use cases, and failure situations.
In the context of the CAP theorem, what are the main features prioritized by a CP (Consistency and Partition tolerance) system?
Explanation: A CP system under the CAP theorem ensures that the system remains consistent and partition tolerant, even if it has to sacrifice availability during network splits. AP systems, on the other hand, focus on availability and partition tolerance. Consistency and availability together are not always guaranteed in partitioned networks. Availability and performance are not one of the CAP categories.
Suppose a network partition occurs. In an AP system, which of the following outcomes is most likely when a user tries to update data?
Explanation: AP systems prioritize availability, so they will process user requests even if this risks temporary inconsistencies between partitions. CP systems would block updates to preserve consistency. Permanent data loss or automatic deletion is not a feature of CAP choices; systems aim to recover or reconcile after partitions are resolved.
When designing a banking system where accurate balances are essential, which system type—CP or AP—is generally preferred?
Explanation: Banking systems require strong consistency to prevent issues such as double spending, making CP systems the preferred choice. AP systems might allow inconsistent balances, which is unsafe in financial contexts. 'PA' and 'AC' are not valid types in the CAP context.
For a social media timeline where freshness is important but strict consistency is not required, which system is most suitable?
Explanation: An AP system can allow users to see updates quickly, even if there are temporary inconsistencies, which is acceptable for most social media timelines. CP systems might block requests during partitions, hurting user experience. 'CA' and 'PC' do not align with the standard CAP division.
Why is partition tolerance considered non-negotiable in large distributed systems?
Explanation: Partition tolerance is essential because network failures are unpredictable and frequent in large-scale distributed systems. Consistency and availability are both often required, but one must be compromised in the presence of partitions. Partition tolerance does not relate to encryption.
Which of the following statements about the CAP theorem is correct?
Explanation: CAP theorem states that in the event of a network partition, a system can provide only two of the three properties. Some believe all can be achieved, but this is only possible in the absence of partitions. Partition tolerance cannot be ignored in distributed systems, and CAP is not about picking just one property.
During a sales event, an online retail platform chooses to accept orders even if backend inventory is temporarily unsynchronized. Which system is this an example of?
Explanation: The system prioritizes availability and partition tolerance, allowing inconsistent data to ensure that sales are not blocked, which is the principle of an AP system. A CP system would not accept updates that could risk inconsistency. 'CA' and 'PA' are not valid CAP categories.
What does 'consistency' mean in the context of CP systems within the CAP theorem?
Explanation: Consistency ensures that every read receives the latest committed value across all nodes after an update. Returning random data or prioritizing availability are not definitions of consistency. Consistency is important for both reads and writes.
Which behavior characterizes the 'availability' property in AP systems under partition conditions?
Explanation: Availability means that clients always receive a response, even during partitions. In AP systems, updates may still go through, risking inconsistency, but data is not deleted, and both reads and writes are supported as long as responses are possible. Blocking updates or allowing only reads is more typical of CP systems.
What usually happens to data in AP systems after a network partition is healed?
Explanation: AP systems reconcile any conflicting updates that occurred during the partition to restore consistency. Permanent data loss, unhealed partitions, or disabling future updates are not intended behaviors. Sure, some reconciliation may require manual intervention or result in last-write-wins policies, but the goal is restored consistency.