# Which side of CAP theorem Elasticsearch satisfy?

**URL:** <https://discuss.elastic.co/t/which-side-of-cap-theorem-elasticsearch-satisfy/177810>\
**Category:** Elasticsearch\
**Created:** [April 22, 2019, 7:38am UTC](https://discuss.elastic.co/t/which-side-of-cap-theorem-elasticsearch-satisfy/177810 "2019-04-22T07:38:45Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [April 22, 2019, 11:52am UTC](https://discuss.elastic.co/t/which-side-of-cap-theorem-elasticsearch-satisfy/177810/2 "2019-04-22T11:52:12Z")

</div>

The CAP theorem is a very specific theorem regarding a particular kind of distributed system called a _linearizable register_ suffering from a network partition that could be pathologically badly behaved. Elasticsearch isn't normally used as a linearizable register, so the CAP theorem doesn't really apply. That said, [Elasticsearch recently gained a feature that adds a compare-and-set operation](https://github.com/elastic/elasticsearch/pull/36467) and [the work to verify that this has linearizable semantics is ongoing](https://github.com/elastic/elasticsearch/pull/38561). In the face of a sufficiently bad network partition, compare-and-set operations in Elasticsearch would preserve consistency and sacrifice availability.

However, [Brewer's conjecture](https://people.eecs.berkeley.edu/~brewer/cs262b-2004/PODC-keynote.pdf) is a more general statement about distributed systems that gave rise to the CAP theorem. It is interesting to ask about Elasticsearch's relationship with this conjecture.

In the face of a sufficiently bad network partition, write operations in Elasticsearch will generally prefer "consistency" over "availability", in the sense that acknowledged writes should never be lost but that some writes may go unacknowledged or may fail. Read operations (i.e. searches) offer stronger availability guarantees at the expense of some consistency, in the sense that a search may sometimes return older results rather than failing. This is normally an appropriate choice for search engines like Elasticsearch. There are mechanisms to prevent the results from being _too_ old.

---

_[View the full topic](https://discuss.elastic.co/t/which-side-of-cap-theorem-elasticsearch-satisfy/177810)._
