Choosing Between CP and AP Systems: Practical Trade-offs Quiz Quiz

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.

  1. AP vs CP Basics

    In the context of the CAP theorem, what are the main features prioritized by a CP (Consistency and Partition tolerance) system?

    1. Availability and Partition tolerance
    2. Availability and Performance
    3. Consistency and Availability
    4. Consistency and Partition tolerance

    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.

  2. Scenario: Network Partition Decision

    Suppose a network partition occurs. In an AP system, which of the following outcomes is most likely when a user tries to update data?

    1. The system permanently loses data
    2. The system deletes the partitioned data automatically
    3. The system allows the update, possibly causing temporary inconsistencies
    4. The system blocks the update to preserve data consistency

    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.

  3. Choosing for a Banking System

    When designing a banking system where accurate balances are essential, which system type—CP or AP—is generally preferred?

    1. CP system
    2. AP system
    3. PA system
    4. AC system

    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.

  4. Trade-off Example: Social Media Timeline

    For a social media timeline where freshness is important but strict consistency is not required, which system is most suitable?

    1. PC system
    2. CP system
    3. CA system
    4. AP system

    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.

  5. Impact of Partition Tolerance

    Why is partition tolerance considered non-negotiable in large distributed systems?

    1. Consistency is never required
    2. Network partitions can always happen unpredictably
    3. Availability is never required
    4. Partition tolerance improves encryption

    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.

  6. Common CAP Myth

    Which of the following statements about the CAP theorem is correct?

    1. CAP requires choosing only one property
    2. Systems can always provide consistency, availability, and partition tolerance at the same time
    3. It is impossible to achieve all three: consistency, availability, and partition tolerance, simultaneously during a partition
    4. Partition tolerance can be sacrificed without impact

    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.

  7. Example: Online Retail Availability

    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?

    1. AP system
    2. PA system
    3. CP system
    4. CA system

    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.

  8. Consistency Guarantee Meaning

    What does 'consistency' mean in the context of CP systems within the CAP theorem?

    1. All nodes show the same data at the same time after an update
    2. Consistency only matters during write operations
    3. Nodes return random data
    4. Every node is always available for updates

    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.

  9. Availability in AP Systems

    Which behavior characterizes the 'availability' property in AP systems under partition conditions?

    1. Updates are only processed once the partition is repaired
    2. Only read operations are allowed during a partition
    3. All data is deleted during a partition
    4. Every request receives a response (success or failure), even during network partitions

    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.

  10. Data Repair After Partition

    What usually happens to data in AP systems after a network partition is healed?

    1. All data is permanently lost
    2. Conflicting updates are reconciled to restore consistency
    3. The partition remains unrepaired
    4. No further updates are allowed

    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.