Course contentsShow
← System Design
Lesson 503 of 1,91914. CAP TheoremFree lesson

Choosing Between CP and AP

Decision framework for selecting CP vs AP based on business requirements, data semantics, and user expectations.

Choosing Between CP and AP

What you'll learn: How to decide whether your system should prioritize consistency (CP) or availability (AP) based on business needs and user expectations.

The Decision Framework

When designing distributed systems, you must choose whether to favor consistency or availability during network partitions. This isn't a coin flip—it's a deliberate decision driven by what your application actually needs.

Key Questions to Ask

What happens if users see stale data?

If outdated information causes financial loss, legal issues, or safety problems, choose CP. If it's merely annoying but tolerable, AP works.

Can your system afford downtime during partitions?

If users can wait or retry later without major impact, CP is viable. If every second of downtime costs revenue or engagement, lean toward AP.

What are your data semantics?

Strong guarantees (bank balances, inventory counts, distributed locks) → CP
Eventually-consistent data (social feeds, recommendations, DNS) → AP

What do users expect?

Banking customers expect correctness, even if it means "try again later." Social media users expect the feed to always load, even if a like count is slightly off.

Making the Call

Think of it like choosing between a bank vault and a convenience store. The vault (CP) stays locked if the alarm system fails—security first. The store (AP) stays open even if the credit card reader breaks—service first.

Key Takeaway: Choose CP when correctness is non-negotiable and temporary unavailability is acceptable; choose AP when continuous service matters more than perfect consistency, and your application can tolerate stale or conflicting data.