Course contentsShow
← Software Engineering
Lesson 923 of 1,93328. Transactions and ConsistencyFree lesson

The Consistency-Availability Trade-off

Understand when to choose eventual consistency over strong consistency based on system requirements and CAP theorem implications.

The Consistency-Availability Trade-off

What you'll learn: How to decide between strong consistency and eventual consistency based on your system's real-world requirements and the CAP theorem.

When Must You Choose?

The CAP theorem tells us distributed systems can't simultaneously guarantee Consistency (all nodes see the same data), Availability (every request gets a response), and Partition tolerance (system works despite network splits). Since partitions happen in real networks, you're forced to choose: when the network fails, do you prioritize consistency or availability?

Making the Choice

Choose strong consistency when:

  • Correctness is non-negotiable (banking transactions, inventory counts)
  • Users expect immediate confirmation that their actions succeeded
  • Inconsistent data would cause serious business problems or legal issues
  • Your system can tolerate brief unavailability during network issues

Choose eventual consistency when:

  • Availability matters more than instant accuracy
  • Users can work with slightly stale data (social media feeds, view counts)
  • The system must remain responsive even during partial failures
  • You can resolve conflicts later without major consequences

Real-World Examples

A shopping cart can use eventual consistency—if one data center is down, users keep shopping. The cart syncs later. But the final checkout payment uses strong consistency—you can't charge twice or lose the transaction.

Social media "like" counts are eventually consistent. If you see 99 likes while someone else sees 100, no harm done. But a seat reservation system needs strong consistency—two people can't book the same seat.

The Gray Area

Many systems use hybrid approaches: eventual consistency for reads, strong consistency for critical writes. You learned about eventual consistency in the previous lesson; now you can apply it strategically rather than as an all-or-nothing decision.

Key Takeaway: Choose strong consistency when correctness is critical and you can tolerate occasional unavailability; choose eventual consistency when availability and responsiveness matter more than instant accuracy across all nodes.