| --- |
| layout: docpage |
| |
| title: "Documentation" |
| |
| is_homepage: false |
| is_sphinx_doc: true |
| |
| doc-parent: "Operating Cassandra" |
| |
| doc-title: "Snitch" |
| doc-header-links: ' |
| <link rel="top" title="Apache Cassandra Documentation v3.11.6" href="../index.html"/> |
| <link rel="up" title="Operating Cassandra" href="index.html"/> |
| <link rel="next" title="Adding, replacing, moving and removing nodes" href="topo_changes.html"/> |
| <link rel="prev" title="Operating Cassandra" href="index.html"/> |
| ' |
| doc-search-path: "../search.html" |
| |
| extra-footer: ' |
| <script type="text/javascript"> |
| var DOCUMENTATION_OPTIONS = { |
| URL_ROOT: "", |
| VERSION: "", |
| COLLAPSE_INDEX: false, |
| FILE_SUFFIX: ".html", |
| HAS_SOURCE: false, |
| SOURCELINK_SUFFIX: ".txt" |
| }; |
| </script> |
| ' |
| |
| --- |
| <div class="container-fluid"> |
| <div class="row"> |
| <div class="col-md-3"> |
| <div class="doc-navigation"> |
| <div class="doc-menu" role="navigation"> |
| <div class="navbar-header"> |
| <button type="button" class="pull-left navbar-toggle" data-toggle="collapse" data-target=".sidebar-navbar-collapse"> |
| <span class="sr-only">Toggle navigation</span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| </button> |
| </div> |
| <div class="navbar-collapse collapse sidebar-navbar-collapse"> |
| <form id="doc-search-form" class="navbar-form" action="../search.html" method="get" role="search"> |
| <div class="form-group"> |
| <input type="text" size="30" class="form-control input-sm" name="q" placeholder="Search docs"> |
| <input type="hidden" name="check_keywords" value="yes" /> |
| <input type="hidden" name="area" value="default" /> |
| </div> |
| </form> |
| |
| |
| |
| <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="../architecture/index.html">Architecture</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="../cql/index.html">The Cassandra Query Language (CQL)</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.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">Cassandra Development</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="../bugs.html">Reporting Bugs and Contributing</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../contactus.html">Contact us</a></li> |
| </ul> |
| |
| |
| |
| </div><!--/.nav-collapse --> |
| </div> |
| </div> |
| </div> |
| <div class="col-md-8"> |
| <div class="content doc-content"> |
| <div class="content-container"> |
| |
| <div class="section" id="snitch"> |
| <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>it teaches Cassandra enough about your network topology to route requests efficiently.</li> |
| <li>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).</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><code class="docutils literal notranslate"><span class="pre">dynamic_snitch</span></code>: whether the dynamic snitch should be enabled or disabled.</li> |
| <li><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.</li> |
| <li><code class="docutils literal notranslate"><span class="pre">dynamic_snitch_reset_interval_in_ms</span></code>: if set greater than zero and read_repair_chance is < 1.0, this will allow |
| ‘pinning’ of replicas to hosts in order to increase cache capacity.</li> |
| <li><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.</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 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="docutils"> |
| <dt>GossipingPropertyFileSnitch</dt> |
| <dd>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.</dd> |
| <dt>SimpleSnitch</dt> |
| <dd>Treats Strategy order as proximity. This can improve cache locality when disabling read repair. Only appropriate for |
| single-datacenter deployments.</dd> |
| <dt>PropertyFileSnitch</dt> |
| <dd>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>.</dd> |
| <dt>Ec2Snitch</dt> |
| <dd>Appropriate for EC2 deployments in a single Region. 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 not work across multiple regions.</dd> |
| <dt>Ec2MultiRegionSnitch</dt> |
| <dd>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).</dd> |
| <dt>RackInferringSnitch</dt> |
| <dd>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.</dd> |
| </dl> |
| </div> |
| </div> |
| |
| |
| |
| |
| <div class="doc-prev-next-links" role="navigation" aria-label="footer navigation"> |
| |
| <a href="topo_changes.html" class="btn btn-default pull-right " role="button" title="Adding, replacing, moving and removing nodes" accesskey="n">Next <span class="glyphicon glyphicon-circle-arrow-right" aria-hidden="true"></span></a> |
| |
| |
| <a href="index.html" class="btn btn-default" role="button" title="Operating Cassandra" accesskey="p"><span class="glyphicon glyphicon-circle-arrow-left" aria-hidden="true"></span> Previous</a> |
| |
| </div> |
| |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |