CAP Theorem
Database Systems
Distributed Computing
System Design
Consistency vs Availability

Consistency over availability in CAP Theorem

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

The CAP Theorem, formulated by Eric Brewer in 2000, delineates the trade-offs between Consistency, Availability, and Partition tolerance in distributed systems. Partition tolerance, in this context, is non-negotiable because network failures are inevitable. Therefore, the primary dilemma for most distributed systems is choosing between consistency and availability. Here, we focus on systems that prioritize consistency over availability, examining what this means practically and theoretically, along with implications, advantages, and potential limitations.

Understanding CAP Theorem Components

Before delving into the nuances of consistency-focused systems, let’s clarify the components of the CAP Theorem:

  • Consistency: Every read operation retrieves the most recent write operation (by any client) or an error.
  • Availability: Every request receives a (non-error) response, without the guarantee that it contains the most recent write.
  • Partition Tolerance: The system continues to operate despite an arbitrary number of messages being dropped (or delayed) by the network between nodes.

When a system prioritizes consistency over availability (C over A), during network partitions or failures, it ensures data consistency at the expense of being unavailable to certain operations until the failure is resolved.

Implications of Consistency over Availability

A typical choice for systems such as banking and financial services, where ensuring that all accounts maintain accurate states following transactions, is crucial even if it means temporal service disruption.

  1. Bank Transactions: In an online banking system, when a network partition or a node failure occurs, it is vital that any transaction conducted—be it a transfer or a payment—is either completely executed or not at all, ensuring no inconsistent states (like duplicate transactions or incorrect balances). The system will refuse transactions until consistency can be assured.
  2. E-Commerce Systems: If a network issue arises during a high-stakes sales event (e.g., Black Friday), a consistency-preferred e-commerce system may block further sales operations rather than risk overselling products that it cannot guarantee stock for.

Theoretical Model: ACID over BASE

When considering database properties, systems that choose consistency over availability often stick to the ACID (Atomicity, Consistency, Isolation, Durability) principles, rather than BASE (Basically Available, Soft state, Eventual consistency) principles. ACID-compliant systems ensure that each transaction is processed reliably and in a manner that safeguards the consistency of the database, adhering closely to the concept of consistency over availability.

Use Cases and Implementations:

  • Databases like Google Spanner focus heavily on consistency by using synchronized clocks (TrueTime API) to ensure transactional consistency across global scales.
  • Apache Hadoop HDFS: Prefers consistency by using file system metadata (NameNode) that acts as a master to control the state of all the file systems; data nodes might be unavailable, but consistency is maintained through replicas.

Trade-Offs and Considerations

Consistency-oriented systems may not suit every scenario. Services requiring maximum uptime, like video streaming or social media platforms, typically prefer availability. User interactions, in these cases, can tolerate some delay in data being consistent across the system.

Comparison Table: Consistency vs. Availability

FactorConsistency FocusedAvailability Focused
PriorityData accuracyService uptime
Network Partition ResponseDeny operations that cannot guarantee data integrityAllow operations that might not be based on latest data but keep the service running
Suited ApplicationsBanking, Finance, Medical recordsSocial media, Streaming media
System ExampleApache Hadoop HDFS, Google SpannerCassandra, Riak
Database PrincipleACIDBASE

Concluding Thoughts

Choosing between consistency and availability largely depends on the specific requirements of the application in question. Systems that require unfailing data integrity (e.g., financial, healthcare) might choose consistency over availability, whilst those prioritizing user experience and uptime might lean towards availability. Each choice has its implications, necessitating a thorough analysis of business needs, technical constraints, and the expected user experience.


Course illustration
Course illustration

All Rights Reserved.