> For the complete documentation index, see [llms.txt](https://gchandra.gitbook.io/big-data-and-tools-with-nosql/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gchandra.gitbook.io/big-data-and-tools-with-nosql/big-data-overview/scaling/cap-theorem.md).

# CAP Theorem

<figure><img src="https://1471795080-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrtXPLjVTxuTGIysjCx89%2Fuploads%2Fv0dodVTCTiBnAD6bZ1sV%2Fimage.png?alt=media&amp;token=730d6c11-beff-436f-9cab-07f1cc696e29" alt=""><figcaption><p>Src: blog.devtrovert.com</p></figcaption></figure>

The CAP Theorem is a fundamental principle in distributed computing. It says that a distributed system can only guarantee two out of the following three properties at the same time:

1. **Consistency**: Every read gets the most recent write or an error. Imagine a library catalog. If you update a book's location, everyone searching for it should see the new location.
2. **Availability**: Every request gets a response without guaranteeing that it contains the most recent write, like a convenience store that's always open but might sometimes run out of your favorite snack.
3. **Partition Tolerance**: The system continues to operate despite some messages being dropped (due to network failures). It's like having a team in different rooms; even if the intercom breaks, they keep working with the info they have.

<figure><img src="https://1471795080-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrtXPLjVTxuTGIysjCx89%2Fuploads%2FM2b4K6GMjU9KnejHXEK9%2Fimage.png?alt=media&amp;token=d32f6875-807d-42a5-bcc6-651bebb207d2" alt=""><figcaption><p>Src: Factor-bytes.com</p></figcaption></figure>

**Real-world examples**

* Social Media
* Financial Systems
* IoT
* eCommerce
* CDN (Content Delivery Networks)
