Snitches

Nir edited this page Jul 10, 2016 · 45 revisions

What is Snitch?

Snitch is a ScyllaDB component that performs the following tasks:

  • Provides a translation from a Node's IP to a Data Center (DC) and a Rack that it belongs to
  • Evaluates the distance (see below) between a group of Nodes to a given Node
  • Enforces using local IPs for connection between two Nodes in the same Data Center

Distance is a metric that may be evaluated differently for different snitch types or/and when a dynamic snitching is enabled. Without a dynamic snitching it's evaluated based on the location in the same DC/Rack as the Node we evaluate a distance to

For Example

  • Node1 is located in DC1, Rack1
  • Node2 is located in DC1, Rack2
  • Node3 is located in DC2, Rack1
  • Node4 is located in DC1, Rack1

Then, if we sort nodes by their distance to Node1, they will be ordered as follows (from the closest to the furthest): Node1, Node4, Node2, Node3

Supported Snitch Types

  • SimpleSnitch
  • RackInferringSnitch
  • GossipingPropertyFileSnitch
  • Ec2Snitch
  • Ec2MultiRegionSnitch

SimpleSnitch

SimpleSnitch is the most simple snitch one can imagine. It would bind all Nodes to the same Rack ('rack1') and DC ('datacenter1')

RackInferringSnitch

RackInferringSnitch would bind Nodes to DCs and Racks according to their Broadcast IPs:

For Example

If Node1 has a Broadcast IP 192.168.100.200, then it would belong to a DC '168' and Rack '100'

GossipingPropertyFileSnitch

While a SimpleSnitch and a RackInferringSnitch are snitches to play with when you do your first steps with ScyllaDB, GossipingPropertyFileSnitch is the first snitch recommended to be used in a production installations. It allows you to explicitly define which DC and Rack a specific Node belongs to

This snitch reads its configuration from a cassandra-rackdc.properties file that will be looked in a $SCYLLA_CONF or in a $SCYLLA_HOME/conf directories

For Example

cassandra-rackdc.properties file:

prefer_local=true 
dc=my_data_center 
rack=my_rack  

The lines may include white spaces at the beginning and the end. The rack and dc values may also include white spaces All trailing and leading white spaces will be trimmed Lines beginning with # symbol will be ignored

  • (optional) prefer_local allowed values are true and false (case sensitive). It defines if a local IP (Listen IP) is going to be used for communication with the Nodes in the same DC
  • dc and rack may have any string as a value and they will be used as a Data Center and a Rack names for this Node

For Example

  • Node1: Broadcast Address 192.168.0.22, Listen Address 10.4.0.1, dc='dc1', rack='rack1'
  • Node2: Broadcast Address 192.168.0.23, Listen Address 10.4.0.2, dc='dc1', rack='rack2'

If Node1's property file has prefer_local=false (or if this property is missing), then when it needs to communicate with Node2 it will connect to 192.168.0.23. Otherwise, if its property file has prefer_local=true then it'll connect to 10.4.0.2

In addition, this snitch will reload the configuration every 60 seconds

Ec2Snitch

Ec2Snitch is a basic snitch that reads its configuration from Amazon's EC2 registry services. Similarly to a GossipingPropertyFileSnitch it reads its configuration from a cassandra-rackdc.properties file. The only configuration property it would use from it is an optional dc_suffix property. Any other properties will be ignored

Ec2Snitch uses a region name a Data Center name and an availability zone as a name of a Rack

For Example

  • If a Node is in a us-west-1 region, then it's DC='us-west' and Rack='1'.
  • If in addition dc_suffix=-my-zone, then DC='us-west-my-zone'

Ec2MultiRegionSnitch

This snitch is just like an Ec2Snitch but it will also set the Broadcast Address and Broadcast Rpc Address of a Node to the Node's public IP

This would allow Nodes from other zones to communicate with this Node regardless of what is configured in the Node's .yaml configuration file for broadcast_address and broadcast_rpc_address keys

Ec2MultiRegionSnitch also unconditionally imposes the "prefer local" policy on a Node (similarly to GossipingPropertyFileSnitch when prefer_local is set to true)

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.