# Scaling-out datastores and the CAP theorem

- Speaker: [Yoav Abrahami](/wiki/speakers/yoav-abrahami.md)
- Event: [Reversim Summit 2014](/wiki/years/2014.md)
- Video: https://www.youtube.com/watch?v=78PApLdvOQo
- Transcript: [/transcripts/2014/10-78PApLdvOQo.md](/transcripts/2014/10-78PApLdvOQo.md)
- Language: Hebrew · Type: talk · Level: intermediate
- Topics: [Distributed Systems](/wiki/topics/distributed-systems.md), [Databases](/wiki/topics/databases.md), [Scalability](/wiki/topics/scalability.md)

> Written by an LLM from machine transcripts. It can contain errors. Check the transcript before you quote it.

## Summary

The speaker explores the CAP theorem and its practical implications on distributed data stores and internet-scale systems. The main argument is that distributed systems must trade off consistency and availability when network partitions occur. The audience learns how popular databases like PostgreSQL and MongoDB behave under network failures and what architectural patterns can be used to handle these tradeoffs.

## Key points

- [1:10](https://www.youtube.com/watch?v=78PApLdvOQo&t=70s) The CAP theorem states that a distributed system cannot simultaneously guarantee consistency, availability, and partition tolerance, forcing designers to choose between them.
- [4:26](https://www.youtube.com/watch?v=78PApLdvOQo&t=266s) Consistency in the CAP theorem differs from ACID consistency as it refers to individual data items rather than the entire database state.
- [6:26](https://www.youtube.com/watch?v=78PApLdvOQo&t=386s) Network partitions are a reality in modern cloud environments, often caused by hardware issues, garbage collection pauses, or cloud provider maintenance.
- [13:50](https://www.youtube.com/watch?v=78PApLdvOQo&t=830s) PostgreSQL can suffer from edge cases during network splits where clients receive timeout errors while transactions actually succeed.
- [19:26](https://www.youtube.com/watch?v=78PApLdvOQo&t=1166s) MongoDB can experience data loss during master failovers unless configured with majority write concerns, which impact performance.
- [33:31](https://www.youtube.com/watch?v=78PApLdvOQo&t=2011s) Immutable data models simplify replication and historical tracking by avoiding destructive update and delete operations.
- [37:53](https://www.youtube.com/watch?v=78PApLdvOQo&t=2273s) BASE systems sacrifice strict consistency for eventual consistency and basic availability to scale in distributed environments.
- [43:31](https://www.youtube.com/watch?v=78PApLdvOQo&t=2611s) Conflict-free Replicated Data Types (CRDTs) and CQRS patterns offer specialized ways to handle eventual consistency in distributed applications.

## Takeaways

- Design systems expecting network partitions because network failures and latency spikes are inevitable.
- Understand the consistency and durability trade-offs of your chosen database configuration, such as write concerns.
- Consider utilizing immutable data and idempotent operations to improve system resilience.

## Questions this talk answers

- How does the CAP theorem apply to real-world distributed databases?
- What happens to unacknowledged database transactions during a network partition?
- How can eventual consistency and CRDTs help manage distributed state?

## Technologies

PostgreSQL, MongoDB, Cassandra, Riak, Git, TCP/IP

## Tags

cap theorem, database consistency, distributed systems, eventual consistency, high availability, replication
