Where to Give Priority: Consistency vs Availability
Quick Reference: CAP Theorem | Data Consistency
Quick Reference
| System Type | Priority | Why | Example |
|---|---|---|---|
| Financial | Consistency | Data accuracy critical | Banking, payments |
| Social Media | Availability | User experience critical | Twitter, Facebook |
| E-commerce | Both (hybrid) | Different for different data | Amazon (inventory CP, catalog AP) |
| Gaming | Availability | Low latency critical | Real-time games |
Clear Definition
This guide helps you decide when to prioritize Consistency vs Availability in your system design. The choice depends on your use case, user expectations, and business requirements. Many systems use a hybrid approach, prioritizing consistency for some data and availability for others.
π‘ Key Insight: Most real-world systems don't choose one exclusively. They use different strategies for different types of data (polyglot consistency).
Decision Framework
When to Prioritize Consistency (CP)
Choose CP when:
-
Data Accuracy Critical
- Financial transactions
- Inventory management
- Medical records
- Impact: Wrong data = serious consequences
-
Users Expect Accuracy
- Banking balances
- Stock prices
- Reservation systems
- Impact: Users trust system accuracy
-
Can Tolerate Downtime
- Internal systems
- Batch processing
- Impact: Short downtime acceptable
When to Prioritize Availability (AP)
Choose AP when:
-
User Experience Critical
- Social media feeds
- Content delivery
- Search results
- Impact: Stale data acceptable, downtime not
-
High Traffic
- Millions of users
- Global distribution
- Impact: Must stay available
-
Stale Data Acceptable
- User profiles
- Recommendations
- Analytics
- Impact: Eventual consistency OK
Hybrid Approaches
Example: E-commerce Platform
CP (Consistency):
- Inventory levels (prevent overselling)
- Payment processing (accuracy critical)
- Order status (must be accurate)
AP (Availability):
- Product catalog (stale data OK)
- User reviews (eventual consistency)
- Recommendations (approximate OK)
Example: Social Media Platform
CP (Consistency):
- User authentication (security critical)
- Direct messages (must be accurate)
- Payment/subscription data
AP (Availability):
- News feeds (stale OK)
- Likes/comments (eventual consistency)
- Trending topics (approximate OK)
Best Practices
- Analyze Data Types: Different data needs different consistency
- User Expectations: What do users expect?
- Business Impact: What happens if data is wrong vs unavailable?
- Hybrid Strategy: Use both CP and AP for different data
- Monitor: Track consistency and availability metrics
Common Pitfalls
β οΈ Common Mistake: Choosing one strategy for entire system.
Solution: Use hybrid approach. Different data needs different consistency.
β οΈ Common Mistake: Not considering user expectations.
Solution: Understand what users expect. Banking = accuracy, Social media = availability.
Interview Tips
π― Interview Focus: Show decision-making process.
Common Questions
- "When would you prioritize consistency over availability?"
- "Design a system that uses both CP and AP strategies."
- "How would you handle consistency in a social media platform?"
Quick Reference Summary
Prioritize Consistency: When data accuracy critical (financial, inventory, medical).
Prioritize Availability: When user experience critical (social media, content, search).
Hybrid Approach: Most systems use bothβCP for critical data, AP for high-volume data.
Previous Topic: CAP Theorem β
Back to: Step 3 Overview | Main Index