Let's say you're building a database that spans multiple machines.
There are all sorts of things it would be nice for your database to support:
- Consistency: Any time you read from the database, you get the most up-to-date data.
- Availability: The database responds to all requests.
- Partition Tolerance: The database works even if the network connecting the machines is flaky.
The CAP Theorem says that you can only have two of these features in your database. You can't build a distributed database with all three.
This theorem highlights the key differences between ACID and BASE databases.
ACID databases prioritize consistency and availability—making sure that the data read are up-to-date—at the expense of partition tolerance— the database won't work unless all machines can communicate and ensure they have the same data.
BASE databases choose partition tolerance and availability— they keep working even if machines can't communicate with each other to synchronize. This gives up consistency, since an update on one machine might not make it to the others.
Interview coming up?
Get the free 7-day email crash course. You'll learn how to think algorithmically, so you can break down tricky coding interview questions.
No prior computer science training necessary—we'll get you up to speed quickly, skipping all the overly academic stuff.
No spam. One-click unsubscribe whenever.
You're in! Head over to your email inbox right now to read day one!
Interview Cake