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: If you give up consistency, two different machines may return different responses for the same query.
- A: If you give up availability, some requests will not be answered if there’s a network problem.
- P: If you give up partition tolerance, some requests will not return as long as there’s a network problem.
Web developers never want to give up P since having a request hang when there’s a network problem is worse than having it fail. 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.