Topology awareness through snitches
Snitches map the IP addresses of nodes to physical and virtual locations, such as racks and datacenters. Snitches use gossip to inform the database about the network topology for efficient request routing and replica distribution in datacenters and racks (logical groups). HCD prioritizes placing replicas on different racks whenever possible. Racks can be logical groupings or physical locations depending on your infrastructure.
HCD supports several types of snitches for different deployment environments and network topologies. All nodes in a cluster must use the same snitch. You can switch snitches after deployment, but this might require additional changes or downtime to redistribute the replicas.
Snitch types
- HcdSimpleSnitch (default)
-
Use this snitch only for non-production single-datacenter deployments or single-zone deployments in public clouds. This snitch does not recognize datacenter or rack information. When using this snitch, keyspace definitions must use the
SimpleStrategyclass and specify a replication factor (1in single-datacenter deployments).
- GossipingPropertyFileSnitch
-
This snitch is recommended for production. It is the most flexible solution for on-premise or mixed cloud environments. It uses rack and datacenter information for the local node defined in the
cassandra-rackdc.propertiesfile and propagates this information to other nodes through gossip.
- PropertyFileSnitch
-
This snitch determines proximity based on the rack and datacenter. It uses the network details located in the
cassandra-topology.propertiesfile, which must include every node in the cluster. All nodes must have a copy of the samecassandra-topology.propertiesfile.When using this snitch, use a standardized naming convention for your datacenters. Keyspace definitions must use the exact datacenter names in the
replicationmap. - RackInferringSnitch
-
This snitch determines the proximity of nodes by datacenter and rack, which are assumed to correspond to the second and third octet of the node’s IP address, respectively. For example, in the IP address
110.100.200.105,100is the datacenter octet,200is the rack octet, and105is the node (host) octet.It is best used as an example for writing a custom snitch class, unless this format happens to match your deployment conventions.
- Cloud provider snitches
-
Use these snitches for deployments in specific cloud environments:
Dynamic snitching
By default, all snitches use a dynamic snitch layer that monitors read latency and, when possible, routes requests away from poorly-performing nodes.
The dynamic snitch is enabled by default and is recommended for use in most deployments.
You can set dynamic snitch thresholds in each node’s cassandra.yaml file.
You can also configure the properties for gossip failure detection and recovery.