blob: 9a8520e3b8528b2d2f4ddce34281e101f7eb99c0 [file] [log] [blame]
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Snitch &mdash; Apache Cassandra Documentation v4.0-rc2</title>
<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" />
<!--[if lt IE 9]>
<script src="../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Adding, replacing, moving and removing nodes" href="topo_changes.html" />
<link rel="prev" title="Operating Cassandra" href="index.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.0-rc2
</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"><a class="reference internal" href="../architecture/index.html">Architecture</a></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 current"><a class="reference internal" href="index.html">Operating Cassandra</a><ul class="current">
<li class="toctree-l2 current"><a class="current reference internal" href="#">Snitch</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#dynamic-snitching">Dynamic snitching</a></li>
<li class="toctree-l3"><a class="reference internal" href="#snitch-classes">Snitch classes</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="topo_changes.html">Adding, replacing, moving and removing nodes</a></li>
<li class="toctree-l2"><a class="reference internal" href="repair.html">Repair</a></li>
<li class="toctree-l2"><a class="reference internal" href="read_repair.html">Read repair</a></li>
<li class="toctree-l2"><a class="reference internal" href="hints.html">Hints</a></li>
<li class="toctree-l2"><a class="reference internal" href="compaction/index.html">Compaction</a></li>
<li class="toctree-l2"><a class="reference internal" href="bloom_filters.html">Bloom Filters</a></li>
<li class="toctree-l2"><a class="reference internal" href="compression.html">Compression</a></li>
<li class="toctree-l2"><a class="reference internal" href="cdc.html">Change Data Capture</a></li>
<li class="toctree-l2"><a class="reference internal" href="backups.html">Backups</a></li>
<li class="toctree-l2"><a class="reference internal" href="bulk_loading.html">Bulk Loading</a></li>
<li class="toctree-l2"><a class="reference internal" href="metrics.html">Monitoring</a></li>
<li class="toctree-l2"><a class="reference internal" href="security.html">Security</a></li>
<li class="toctree-l2"><a class="reference internal" href="hardware.html">Hardware Choices</a></li>
</ul>
</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" class="icon icon-home"></a> &raquo;</li>
<li><a href="index.html">Operating Cassandra</a> &raquo;</li>
<li>Snitch</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/operating/snitch.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="snitch">
<span id="id1"></span><h1>Snitch<a class="headerlink" href="#snitch" title="Permalink to this headline"></a></h1>
<p>In cassandra, the snitch has two functions:</p>
<ul class="simple">
<li><p>it teaches Cassandra enough about your network topology to route requests efficiently.</p></li>
<li><p>it allows Cassandra to spread replicas around your cluster to avoid correlated failures. It does this by grouping
machines into “datacenters” and “racks.” Cassandra will do its best not to have more than one replica on the same
“rack” (which may not actually be a physical location).</p></li>
</ul>
<div class="section" id="dynamic-snitching">
<h2>Dynamic snitching<a class="headerlink" href="#dynamic-snitching" title="Permalink to this headline"></a></h2>
<p>The dynamic snitch monitor read latencies to avoid reading from hosts that have slowed down. The dynamic snitch is
configured with the following properties on <code class="docutils literal notranslate"><span class="pre">cassandra.yaml</span></code>:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">dynamic_snitch</span></code>: whether the dynamic snitch should be enabled or disabled.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">dynamic_snitch_update_interval_in_ms</span></code>: controls how often to perform the more expensive part of host score
calculation.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">dynamic_snitch_reset_interval_in_ms</span></code>: if set greater than zero, this will allow ‘pinning’ of replicas to hosts
in order to increase cache capacity.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">dynamic_snitch_badness_threshold:</span></code>: The badness threshold will control how much worse the pinned host has to be
before the dynamic snitch will prefer other replicas over it. This is expressed as a double which represents a
percentage. Thus, a value of 0.2 means Cassandra would continue to prefer the static snitch values until the pinned
host was 20% worse than the fastest.</p></li>
</ul>
</div>
<div class="section" id="snitch-classes">
<h2>Snitch classes<a class="headerlink" href="#snitch-classes" title="Permalink to this headline"></a></h2>
<p>The <code class="docutils literal notranslate"><span class="pre">endpoint_snitch</span></code> parameter in <code class="docutils literal notranslate"><span class="pre">cassandra.yaml</span></code> should be set to the class that implements
<code class="docutils literal notranslate"><span class="pre">IEndPointSnitch</span></code> which will be wrapped by the dynamic snitch and decide if two endpoints are in the same data center
or on the same rack. Out of the box, Cassandra provides the snitch implementations:</p>
<dl class="simple">
<dt>GossipingPropertyFileSnitch</dt><dd><p>This should be your go-to snitch for production use. The rack and datacenter for the local node are defined in
cassandra-rackdc.properties and propagated to other nodes via gossip. If <code class="docutils literal notranslate"><span class="pre">cassandra-topology.properties</span></code> exists,
it is used as a fallback, allowing migration from the PropertyFileSnitch.</p>
</dd>
<dt>SimpleSnitch</dt><dd><p>Treats Strategy order as proximity. This can improve cache locality when disabling read repair. Only appropriate for
single-datacenter deployments.</p>
</dd>
<dt>PropertyFileSnitch</dt><dd><p>Proximity is determined by rack and data center, which are explicitly configured in
<code class="docutils literal notranslate"><span class="pre">cassandra-topology.properties</span></code>.</p>
</dd>
<dt>Ec2Snitch</dt><dd><p>Appropriate for EC2 deployments in a single Region, or in multiple regions with inter-region VPC enabled (available
since the end of 2017, see <a class="reference external" href="https://aws.amazon.com/about-aws/whats-new/2017/11/announcing-support-for-inter-region-vpc-peering/">AWS announcement</a>).
Loads Region and Availability Zone information from the EC2 API. The Region is treated as the datacenter, and the
Availability Zone as the rack. Only private IPs are used, so this will work across multiple regions only if
inter-region VPC is enabled.</p>
</dd>
<dt>Ec2MultiRegionSnitch</dt><dd><p>Uses public IPs as broadcast_address to allow cross-region connectivity (thus, you should set seed addresses to the
public IP as well). You will need to open the <code class="docutils literal notranslate"><span class="pre">storage_port</span></code> or <code class="docutils literal notranslate"><span class="pre">ssl_storage_port</span></code> on the public IP firewall
(For intra-Region traffic, Cassandra will switch to the private IP after establishing a connection).</p>
</dd>
<dt>RackInferringSnitch</dt><dd><p>Proximity is determined by rack and data center, which are assumed to correspond to the 3rd and 2nd octet of each
node’s IP address, respectively. Unless this happens to match your deployment conventions, this is best used as an
example of writing a custom Snitch class and is provided in that spirit.</p>
</dd>
</dl>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="topo_changes.html" class="btn btn-neutral float-right" title="Adding, replacing, moving and removing nodes" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
<a href="index.html" class="btn btn-neutral float-left" title="Operating Cassandra" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&#169; Copyright 2020, The Apache Cassandra team.
</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/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>