When dealing with distributed systems, Brewer’s CAP theorem is often brought up when discussing how a system will behave in certain error conditions. The CAP theorem means that you can only have two of: consistency, availability, and partition tolerance.
Here’s what you’ll be giving up for each of the three that you may sacrifice:
- C: Consistency means that two different machines will return the same responses for the same query.
- A: Availability means that requests will be answered even if a machine goes down.
- P: Partition tolerance means that the system continues to function even if there’s a network outage that stops communication.
Web developers rarely want to give up P since that means you could get split brain syndome where the data is out-of-sync between machines. As a web developer, CAP means you must make the choice between having a site that never goes down, but regularly return stale data or a site that never returns stale data, but goes down if there’s a problem. Thus the real choice is between C and A in this context. A bank website would choose consistency over availability. Getting the balance in someone’s account wrong is worse than having the site be down. Google chose availability, which is why you never see it go down. The tradeoff is that it may be looking at a slightly stale version of the index when ranking some queries.