Page 73 - Building Big Data Applications
P. 73
Chapter 2 Infrastructure and technology 67
on the ring and assigns the range of data it is responsible for. Once the assignment is
done, we cannot undo it without reloading all the data.
Cassandra provides native partitioners and supports any user-defined partitioner.
The key feature difference in the native partitioner is the order preservation of keys.
Random Partitionerdis the default choice for Cassandra. It uses an MD5 hash
function to map keys into tokens, which will evenly distribute across the clusters.
Random partitioning hashing techniques ensures that when nodes are added to the
cluster, the least possible set of data is affected. While the keys are evenly distributed,
there is no ordering of the data, which will need the query to be processed by all nodes in
an operation.
Ordered preserving partitionersdas the name suggests, preserves the order of the
row keys as they are mapped into the token space. Since the key is placed based on
ordered list of values, we can run efficient rangeebased data retrieval techniques. The
biggest drawback in this design is a node with its replicas may become unstable over
time especially with large reads or writes being done in one node.
Peer to peerdsimple scalability
Cassandra by design is a peer to peer model of architecture, meaning in its configu-
ration there are no designated master or slave nodes. The simplicity of this design
allows nodes to be taken down from a cluster or added to a cluster with ease. When a
node is down, the processing is taken over by the replicas and allows for a graceful
shutdown, similarly when a node is added to a cluster, upon being designated with its
keys and tokens, the node will join the cluster and understand the topology before
commencing operations.
Gossip protocoldnode management
In Cassandra architecture, to manage partition tolerance and decentralization of data,
managing intranode communication becomes a key feature. This is accomplished by
using the gossip protocol. Alan Demers, a researcher at Xerox’s Palo Alto Research
Center, who was studying ways to route information through unreliable networks,
originally coined the term “gossip protocol” in 1987.
In Cassandra, the gossip protocol is implemented as gossiper class. When a node is
added to the cluster it also registers with the gossiper to receive communication. The
gossiper selects a random node and checks it for being alive or dead, by sending mes-
sages to the node. If a node is found to be unresponsive, the gossiper class triggers the
“hinted handoff” process if configured. In order for the gossiper class to distinguish
between failure detection and long running transactions, Cassandra implements another
algorithm called “Phi Accrual Failure Detection algorithm” (based on the popular paper
by Naohiro Hayashibara et al.). According to the “accrual detection” algorithm, a node
can be marked as suspicious based on the time it takes to respond and more the delays,
higher the suspicion that the node is dead. This delay or accrued value is calculated by