Open In App
Related Articles

Snitches in Cassandra

Improve Article
Save Article
Like Article

In this article, we will discuss the Snitch and its types and Understanding how to configure the and files helps configure data centers and clusters. 

Snitches : 
In Cassandra Snitch is very useful and snitch is also helps in keep record to avoid storing multiple replicas of data on the same rack. In Cassandra, it is very important aspects to avoid multiple replica. In replication strategy we assign number of replica and also we define the data-center. This information is very helpful for snitch to identify the node and which rack belong to. 

In Cassandra, snitch job is to determine which data centers and racks it should use to read data from and write data to. In Cassandra, all snitch are dynamic by default. 

Types of Snitches: 

  1. SimpleSnitch: 
    In Cassandra, It is default snitch and good for development environments. It is unaware of datacenters or racks and also is not look for file and therefore is unusable for multi-datacenter environments. 
  2. GossipingPropertyFileSnitch: 
    In Cassandra, it is very important file snitch also recommends by datastax for production usage. This snitch also look for the file to identify the cluster information such that which data center and rack belong to then we configure in the file to the rest of the nodes using gossip. 

    We can configure the GossipingPropertyFileSnitch by editing the file. 
    Let’s have a look.

  1. Here, we are using dc and rack which refers to datacenter and rack and prefer_local=true refers to communicate with local IP address while it is not communicating in multiple data center in order to limit the network bandwidth usage. 
  2. Ec2Snitch: 
    It is important snitch for deployments and it is a simple snitch for Amazon EC2 deployments where all nodes are in a single region. In Ec2Snitch region name refers to data center and availability zone refers to rack in a cluster. 


  3. Ec2MultiRegionSnitch: 
    In Cassandra, this snitch we use where the clusters span multiple regions and Ec2MultiRegionSnitch for Amazon EC2-based clusters. 


  4. GoogleCloudSnitch: 
    In Cassandra, it is the snitch for a Cassandra deployment on the Google Cloud Platform (GCP) across a single or multiple regions. It is the snitch which supports GCP (Google Cloud Plateform). 


  5. RackInferringSnitch: 
    In this snitch we find out the location by rack and datacenter. In this snitch the 3rd and 4th octets of IP address for example corresponds to rack and datacenter. This is very useful snitch for writing custom snitch classes. 


  6. PropertyFileSnitch: 
    This snitch uses the file and we must define the nodes information by which we can Determines the closeness of the nodes. 
    We can identify nodes information based on the datacenter and rack which they belong to. To determine the closeness of the nodes The PropertyFileSnitch used the network definitions from the file. 


  7. CloudstackSnitch: 
    It is the snitch which based on cloud and It is snitch for an Apache Cloudstack-based cluster. 


Now, let’s understand the and the Files. 

Understanding the and the Files: 

It contains the topology of entire cluster and the information of the and the Files. 
Let’s take an example. 

dc = DC1
rack = RAC1 
rack= RAC2

In below given example DC1 and DC2 are two physical datacenters and there are two rack for each of them. In Cassandra The PropertyFileSnitch uses the properties file which is file to identify the cluster’s node. If we don’t identify cluster’s nodes in the file then database assumes that data are in default datacenter and rack. 

# datacenter One  = DC1:RAC1  = DC1:RAC1  = DC1:RAC1  = DC1:RAC2  = DC1:RAC2  = DC1:RAC2

# datacenter Two  = DC2:RAC1  = DC2:RAC1  = DC2:RAC1  = DC2:RAC2  = DC2:RAC2  = DC2:RAC2 

The file is very important to update while we are going to add or delete nodes from cluster then to make aware that the nodes belong to which datacenter and rack. from performance perspective it is very important to keep record that information to Cassandra. 

Here, we are going to describe the file: In above given example we are using following information of node. 
Let’s have a look. 


There are following snitch types look up the file for identifying the nodes cluster information such that which data center and which rack belong to. 
Let’s have a look. 



Unlock the Power of Placement Preparation!
Feeling lost in OS, DBMS, CN, SQL, and DSA chaos? Our Complete Interview Preparation Course is the ultimate guide to conquer placements. Trusted by over 100,000+ geeks, this course is your roadmap to interview triumph.
Ready to dive in? Explore our Free Demo Content and join our Complete Interview Preparation course.

Last Updated : 16 Jan, 2022
Like Article
Save Article
Similar Reads