NoSQL: Cassandra Architecture – Read and Write operations in The Ring (Day 2)

On the previous day, I have shared some of the important key concepts of the Cassandra Architecture.
In this post, I am sharing the basic about read and write operations architecture of Cassandra.

Cassandra Ring:

Cassandra is using a consistent hashing algorithm to treat all nodes of the cluster equally.

NoSQL Cassandra Ring

A Cassandra cluster is visualised as a Ring in which different nodes are participating with the same name. It can exchange state information with a maximum of three other nodes.
A token range assigned to each node which determines its position in the cluster.

Cassandra is using Gossip Protocol so whenever any node starts, it obtains information about the other nodes by exchanging information with each other.

A Partitioner is responsible to prepare set of data for each node.
Cassandra has three different types of Partitioners, Murmur3Partitioner (default), RandomPartitioner and a ByteOrderedPartitioner.

Each node is performing replicates of data base on defined replication strategy. Basically there two types of replication strategy, one is Simple Strategy and second is Network Topology Strategy.
A Simple Strategy works in the clockwise and Network Topology basically works for multiple data centres.

How It executes Write Operations?

A Cassandra is Masterless distributed architecture and there is no any Master and Slave mechanism like any other distributed system.

NoSQL Cassandra Architecture

At any given point of time, the client can connect to any node and that connected node called as a coordinator.
Based on the partition key and replication strategy, Coordinator forwards and replicates data to all applicable nodes.

Each node processes the request individually.
Every node first writes data into the commit log and then writes into the memtable.

The commit log ensures the durability because memtable is dealing with memory so whenever data is lost then we can use commit log to restore the data.
Whenever memtable is flushed or full, it is written to the SSTable (Sorted String Table) of the disk.

Every SSTable creates three files on the disk which include a bloom filter, a key index and a data file. Over a period of time a number of SSTables are created.

How It executes Read Operations?

As Cassandra is Masterless architecture so clients can connect to any node of the cluster ring.
Like write operation, chosen node is called as coordinator and is responsible for returning the requested data.

A row key must be supplied for every read operation. The coordinator uses the row key to determine the first replica.

If replica has a different version of the data, coordinator returns the latest version to the client by issuing read repair command with the older version of the data.

Each read request fetches the data from memtable and SSTables after that it merged this data and returned to the coordinator.
Internally SSTables are using a Bloom Filter to check requested row key weather it is exists in SSTable or not.

Anvesh Patel

Leave a Reply

Be the First to Comment!

Notify of