ACID vs BASE Properties
Two opposing philosophies for database consistency and availability trade-offs.
1The Bank vs Social Media Analogy
BASE (Social Media Likes): If a like count shows 999 instead of 1000 for a few seconds, nobody cares. Eventually it'll be correct. Speed and availability matter more.
2ACID Properties
ACID is a set of properties that guarantee database transactions are processed reliably, even in the face of errors, power failures, etc.
Atomicity
All or nothing. Transaction either fully completes or fully rolls back. No partial updates.
Example: Transfer fails mid-way? Both accounts return to original state.
Consistency
Database moves from one valid state to another. All rules/constraints are enforced.
Example: Account balance can't go negative if that's a constraint.
Isolation
Concurrent transactions don't interfere. Each sees a consistent view.
Example: Two transfers happening simultaneously won't corrupt data.
Durability
Once committed, data survives crashes. Written to persistent storage.
Example: Power failure after commit? Data is still there on restart.
3BASE Properties
BASE is an alternative model that prioritizes availability and partition tolerance over strong consistency.
Basically Available
System guarantees availability. Responses may be stale or partial, but always responds.
Example: Shopping cart always loads, even if inventory count is slightly off.
Soft State
State may change over time without input due to eventual consistency.
Example: Replicas may show different values temporarily.
Eventually Consistent
Given enough time without updates, all replicas will converge to same value.
Example: After a few seconds, all nodes show the same like count.
4Comparison
| Aspect | ACID | BASE |
|---|---|---|
| Consistency | Strong | Eventual |
| Availability | May block for consistency | Always available |
| Scalability | Harder to scale | Horizontally scalable |
| Use Case | Finance, inventory | Social, caching, analytics |
| Databases | PostgreSQL, MySQL | Cassandra, DynamoDB, MongoDB |
5When to Use Which
Choose ACID
- ✓ Financial transactions
- ✓ Inventory management
- ✓ Booking systems
- ✓ Any "correctness is critical" scenario
Choose BASE
- ✓ Social media feeds
- ✓ Analytics/metrics
- ✓ Shopping carts (before checkout)
- ✓ Any "availability is critical" scenario
6Key Takeaways
?Quiz
1. A bank account balance must never be negative. Which ACID property ensures this?
2. Social media like counts being slightly off for a few seconds is acceptable because of: