blob: c4ed301950f9a925af5dffa527004ed09a690971 [file] [log] [blame]
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Guarantees &mdash; Apache Cassandra Documentation v4.1</title>
<script type="text/javascript" src="../_static/js/modernizr.min.js"></script>
<script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="../_static/language_data.js"></script>
<script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/extra.css" type="text/css" />
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="The Cassandra Query Language (CQL)" href="../cql/index.html" />
<link rel="prev" title="Storage Engine" href="storage_engine.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../index.html" class="icon icon-home"> Apache Cassandra
</a>
<div class="version">
4.1
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../getting_started/index.html">Getting Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="../new/index.html">New Features in Apache Cassandra 4.0</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Architecture</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="overview.html">Overview</a></li>
<li class="toctree-l2"><a class="reference internal" href="dynamo.html">Dynamo</a></li>
<li class="toctree-l2"><a class="reference internal" href="storage_engine.html">Storage Engine</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Guarantees</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#what-is-cap">What is CAP?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#high-scalability">High Scalability</a></li>
<li class="toctree-l3"><a class="reference internal" href="#high-availability">High Availability</a></li>
<li class="toctree-l3"><a class="reference internal" href="#durability">Durability</a></li>
<li class="toctree-l3"><a class="reference internal" href="#eventual-consistency">Eventual Consistency</a></li>
<li class="toctree-l3"><a class="reference internal" href="#lightweight-transactions-with-linearizable-consistency">Lightweight transactions with linearizable consistency</a></li>
<li class="toctree-l3"><a class="reference internal" href="#batched-writes">Batched Writes</a></li>
<li class="toctree-l3"><a class="reference internal" href="#secondary-indexes">Secondary Indexes</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../cql/index.html">The Cassandra Query Language (CQL)</a></li>
<li class="toctree-l1"><a class="reference internal" href="../data_modeling/index.html">Data Modeling</a></li>
<li class="toctree-l1"><a class="reference internal" href="../configuration/index.html">Configuring Cassandra</a></li>
<li class="toctree-l1"><a class="reference internal" href="../operating/index.html">Operating Cassandra</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tools/index.html">Cassandra Tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="../troubleshooting/index.html">Troubleshooting</a></li>
<li class="toctree-l1"><a class="reference internal" href="../development/index.html">Contributing to Cassandra</a></li>
<li class="toctree-l1"><a class="reference internal" href="../faq/index.html">Frequently Asked Questions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../plugins/index.html">Third-Party Plugins</a></li>
<li class="toctree-l1"><a class="reference internal" href="../bugs.html">Reporting Bugs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../contactus.html">Contact us</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">Apache Cassandra</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html">Docs</a> &raquo;</li>
<li><a href="index.html">Architecture</a> &raquo;</li>
<li>Guarantees</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/architecture/guarantees.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="guarantees">
<span id="id1"></span><h1>Guarantees<a class="headerlink" href="#guarantees" title="Permalink to this headline"></a></h1>
<p>Apache Cassandra is a highly scalable and reliable database. Cassandra is used in web based applications that serve large number of clients and the quantity of data processed is web-scale (Petabyte) large. Cassandra makes some guarantees about its scalability, availability and reliability. To fully understand the inherent limitations of a storage system in an environment in which a certain level of network partition failure is to be expected and taken into account when designing the system it is important to first briefly introduce the CAP theorem.</p>
<div class="section" id="what-is-cap">
<h2>What is CAP?<a class="headerlink" href="#what-is-cap" title="Permalink to this headline"></a></h2>
<p>According to the CAP theorem it is not possible for a distributed data store to provide more than two of the following guarantees simultaneously.</p>
<ul class="simple">
<li><p>Consistency: Consistency implies that every read receives the most recent write or errors out</p></li>
<li><p>Availability: Availability implies that every request receives a response. It is not guaranteed that the response contains the most recent write or data.</p></li>
<li><p>Partition tolerance: Partition tolerance refers to the tolerance of a storage system to failure of a network partition. Even if some of the messages are dropped or delayed the system continues to operate.</p></li>
</ul>
<p>CAP theorem implies that when using a network partition, with the inherent risk of partition failure, one has to choose between consistency and availability and both cannot be guaranteed at the same time. CAP theorem is illustrated in Figure 1.</p>
<div class="figure align-default">
<img alt="../_images/Figure_1_guarantees.jpg" src="../_images/Figure_1_guarantees.jpg" />
</div>
<p>Figure 1. CAP Theorem</p>
<p>High availability is a priority in web based applications and to this objective Cassandra chooses Availability and Partition Tolerance from the CAP guarantees, compromising on data Consistency to some extent.</p>
<p>Cassandra makes the following guarantees.</p>
<ul class="simple">
<li><p>High Scalability</p></li>
<li><p>High Availability</p></li>
<li><p>Durability</p></li>
<li><p>Eventual Consistency of writes to a single table</p></li>
<li><p>Lightweight transactions with linearizable consistency</p></li>
<li><p>Batched writes across multiple tables are guaranteed to succeed completely or not at all</p></li>
<li><p>Secondary indexes are guaranteed to be consistent with their local replicas data</p></li>
</ul>
</div>
<div class="section" id="high-scalability">
<h2>High Scalability<a class="headerlink" href="#high-scalability" title="Permalink to this headline"></a></h2>
<p>Cassandra is a highly scalable storage system in which nodes may be added/removed as needed. Using gossip-based protocol a unified and consistent membership list is kept at each node.</p>
</div>
<div class="section" id="high-availability">
<h2>High Availability<a class="headerlink" href="#high-availability" title="Permalink to this headline"></a></h2>
<p>Cassandra guarantees high availability of data by implementing a fault-tolerant storage system. Failure detection in a node is detected using a gossip-based protocol.</p>
</div>
<div class="section" id="durability">
<h2>Durability<a class="headerlink" href="#durability" title="Permalink to this headline"></a></h2>
<p>Cassandra guarantees data durability by using replicas. Replicas are multiple copies of a data stored on different nodes in a cluster. In a multi-datacenter environment the replicas may be stored on different datacenters. If one replica is lost due to unrecoverable node/datacenter failure the data is not completely lost as replicas are still available.</p>
</div>
<div class="section" id="eventual-consistency">
<h2>Eventual Consistency<a class="headerlink" href="#eventual-consistency" title="Permalink to this headline"></a></h2>
<p>Meeting the requirements of performance, reliability, scalability and high availability in production Cassandra is an eventually consistent storage system. Eventually consistent implies that all updates reach all replicas eventually. Divergent versions of the same data may exist temporarily but they are eventually reconciled to a consistent state. Eventual consistency is a tradeoff to achieve high availability and it involves some read and write latencies.</p>
</div>
<div class="section" id="lightweight-transactions-with-linearizable-consistency">
<h2>Lightweight transactions with linearizable consistency<a class="headerlink" href="#lightweight-transactions-with-linearizable-consistency" title="Permalink to this headline"></a></h2>
<p>Data must be read and written in a sequential order. Paxos consensus protocol is used to implement lightweight transactions. Paxos protocol implements lightweight transactions that are able to handle concurrent operations using linearizable consistency. Linearizable consistency is sequential consistency with real-time constraints and it ensures transaction isolation with compare and set (CAS) transaction. With CAS replica data is compared and data that is found to be out of date is set to the most consistent value. Reads with linearizable consistency allow reading the current state of the data, which may possibly be uncommitted, without making a new addition or update.</p>
</div>
<div class="section" id="batched-writes">
<h2>Batched Writes<a class="headerlink" href="#batched-writes" title="Permalink to this headline"></a></h2>
<p>The guarantee for batched writes across multiple tables is that they will eventually succeed, or none will. Batch data is first written to batchlog system data, and when the batch data has been successfully stored in the cluster the batchlog data is removed. The batch is replicated to another node to ensure the full batch completes in the event the coordinator node fails.</p>
</div>
<div class="section" id="secondary-indexes">
<h2>Secondary Indexes<a class="headerlink" href="#secondary-indexes" title="Permalink to this headline"></a></h2>
<p>A secondary index is an index on a column and is used to query a table that is normally not queryable. Secondary indexes when built are guaranteed to be consistent with their local replicas.</p>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="../cql/index.html" class="btn btn-neutral float-right" title="The Cassandra Query Language (CQL)" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="storage_engine.html" class="btn btn-neutral float-left" title="Storage Engine" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2020, The Apache Cassandra team
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>