Appendix 2
The CAP Theorem

Understanding the five database genres is important when deciding on which database to use in a particular case, but there’s one other major thing that you should always bear in mind. A recurring theme in this book has been the CAP theorem, which lays bare an unsettling truth about how distributed database systems behave in the face of network instability.

CAP proves that you can create a distributed database that can have one or more of the following qualities: It can be consistent (writes are atomic and all subsequent requests retrieve the new value), available (the database will always return a value as long as a single server is running), and/or partition tolerant (the system will still function even if server communication is temporarily lost—that is, a network partition). But the catch is that any given system can be at most two of these things at once, and never all three.

In other words, you can create a distributed database system that is consistent and partition tolerant (a “CP” system), a system that is available and partition tolerant (an “AP” system), or a system that is consistent and available (the much more rare CA system that is not partition tolerant—which basically means not distributed). Or a system can have only one of those qualities (this book doesn’t cover any databases like that, and you’re unlikely to encounter such a database in wide use). But at the end of the day it simply isn’t possible to create a distributed database that is consistent and available and partition tolerant at the same time, and anyone who says that they’ve “solved CAP” is saying that they’ve defied the laws of physics and thus should not be trusted.

The CAP theorem is pertinent when considering a distributed database because it forces you to decide what you are willing to give up. The database you choose will lose either availability or consistency. Partition tolerance is strictly an architectural decision (depending on whether you want a distributed database). It’s important to understand the CAP theorem to fully grok your options. The trade-offs made by the database implementations in this book are largely influenced by it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset