Blog_Banner_Asset
    Homebreadcumb forward arrow iconBlogbreadcumb forward arrow iconBig Databreadcumb forward arrow iconCassandra Architecture Explained: A Comprehensive Tutorial

Cassandra Architecture Explained: A Comprehensive Tutorial

Last updated:
10th Mar, 2021
Views
Read Time
7 Mins
share image icon
In this article
Chevron in toc
View All
Cassandra Architecture Explained: A Comprehensive Tutorial

Since its inception at Facebook, Cassandra has become one of the most popular Apache projects. It is a widely-used open-source, high performance and distributed database and makes the lives of software engineers, data scientists, and web developers easier. 

The users of this robust database solution include the likes of IBM, Facebook, Reddit, eBay, and Twitter.  

However, to get familiar with Cassandra, you must know about its architecture and Apache Cassandra architecture can be a little tricky to understand. 

That’s why we have created the following introductory guide on Cassandra architecture. It will make you familiar with all the necessary concepts of Cassandra architecture:

Ads of upGrad blog

Basics of Cassandra Architecture

The Apache Cassandra architecture has no master or slave nodes. Instead, it has a ring-like architecture where the nodes are logically distributed in a ring. The architecture allows data to be distributed automatically across all nodes. Like HDFS, data in Cassandra gets replicated across the nodes for redundancy and is stored in memory. It uses the hash values of the keys to distribute data among the nodes in the cluster. 

The Cassandra architecture allows the system to function irrespective of a single point of failure. This means if a cluster has a hundred nodes and one of them fails, the cluster would still be running. On the other hand, with Hadoop, the failure of a namenode would fail the entire system. 

Cassandra architecture offers high scalability so a cluster can even have thousands of nodes. Moreover, you can add a new node to a cluster without interrupting its operations. 

Apart from the features, we discussed above, Apache Cassandra architecture also supports multiple data centres and enables data replication across data centres. 

Topology and Design

Cassandra architecture is based on a distributed system architecture. The simplest version of Cassandra can run on one machine and work well with basic testing. One Cassandra instance is called a node. 

Cassandra offers horizontal scalability where you can add more than one node as a component of a cluster. It works with peer to peer architecture where each node is connected to every other node. Every Cassandra node performs all database operations and servers client requests without a master node. 

Explore our Popular Software Engineering Courses

This peer-to-peer distributed architecture ensures that a single point of failure doesn’t cause the entire system to fail. Clusters in Cassandra can communicate with each other for numerous functions. The following concepts are vital for such communication:

Gossip

Gossip is a Cassandra protocol its nodes use for peer-to-peer communication. It informs a node about the other nodes’ states. Every second, one node performs gossip with up to three other nodes and every gossip message follows specific formats and version numbers to keep the communication efficient. 

Explore Our Software Development Free Courses

Seeds

Every node in Cassandra configures a list of seeds which is a list of other nodes. A seed node doesn’t have any purpose other than bootstrapping a node when it first joins a cluster. After bootstrap, a node doesn’t require a seed on restarting. It’s best to use two or three seed nodes per Cassandra data centre and keep the seeds list uniform.  

Database Structure

In Cassandra, data is stored in tables where every table is organized into rows and columns. Moreover, tables in Cassandra are grouped in keyspaces such as tables on customer data can all be grouped in one keyspace while tables on business transactions can be stored in another.

Every table has a primary key which is divided into clustering columns and partition key. Note that the clustering columns are optional. Cassandra uses the partition key to index the data. All the rows with a common partition key constitute one data partition, the basic unit for data partitioning. 

In-Demand Software Development Skills

Partitioning in Cassandra

In Cassandra, a partitioner converts partition keys into tokens. There are multiple partitioner options present in Cassandra where the Murmur3Partitioner is the default. Every token is assigned an integer value between -2^63 to +2^63-1, and the name of this range is the token range. 

Every Cassandra owns a part of this range and it mainly possesses data related to the range. We use a token to locate the data precisely among the nodes. 

You can understand the ownership system with this concept: If a cluster has only one node then that node would own the complete token range. With the addition of more nodes, the token range ownership would get split accordingly. 

Read our Popular Articles related to Software Development

Virtual Nodes

Cassandra simplifies the token calculation and assignment challenges by using virtual nodes, also known as Vnodes. 

It divides a cluster into numerous virtual nodes to assign tokens and every physical node gets an equal quantity of Vnodes. The default number of Vnodes owned by a node is 256. You can set the same by using the num_tokens property. When you add a new node to a cluster, the token allocation algorithm would allocate the required tokens by using the Vnodes. 

Replication

Cassandra replicates the data present in every keyspace with a replication factor. One primary replica of the data remains with the token owner node while the rest are placed by Cassandra on particular nodes through its replica placement strategy. Note that all replicas have equal importance for most database operations. 

Two settings affect replica placement in Cassandra, which are snitch and the replication strategy. Snitch determines the data centre and the rack a node belongs to. They are responsible for informing Cassandra about the topology for keeping things efficient.

The replication strategy is set at the keyspace level and there are two of them: NetworkTopologyStrategy and simple strategy. The former is a rack and data centre aware while the latter is not. 

CAP Theorem

Every distributed system works based on the CAP theorem. According to this theorem, any distributed system can properly deliver any two out of the three properties, Consistency, Availability, and Partition-tolerance. 

In Cassandra, you can choose between availability and consistency. This means the data can either be highly consistent with lower availability or highly available with low consistency. 

The concept of requesting a specific number of acknowledgements is called tunable consistency and you can apply it at the individual query level. 

Write Process

In this process, the data is written to a comment log on a disk and then sent to a responsible node according to the hash value. 

After that, nodes write data to an in-memory table called memtable from where the data is written to a “sstable” in memory. Next, it gets updated to the actual table. 

If the responsible node is down for some reason, the data gets written to another node.

Learn More About the Cassandra Architecture

Understanding Apache Cassandra architecture would help you understand how this solution works. By now, you also know why Cassandra stands out in the competition and why it’s so popular. 

If you’re interested in learning more about databases, you can check out the following resources:

SQL for Data Science: Why SQL, List of Benefits & Commands

20 Most Common SQL Interview Questions & Answers [For Freshers]

SQL Free Online Course with Certificate [2022-23]

Ads of upGrad blog

On the other hand, if you’re looking for a personalized learning experience, we recommend taking a data science course. At upGrad, we offer a PG Diploma in Data Science and a Master of Science in Data Science. These courses will teach you all the necessary skills to become a data science professional. 

Conclusion 

If you are interested to know more about Big Data, check out our Advanced Certificate Programme in Big Data from IIIT Bangalore.

Check our other Software Engineering Courses at upGrad.

Profile

Rohit Sharma

Blog Author
Rohit Sharma is the Program Director for the UpGrad-IIIT Bangalore, PG Diploma Data Analytics Program.
Get Free Consultation

Selectcaret down icon
Select Area of interestcaret down icon
Select Work Experiencecaret down icon
By clicking 'Submit' you Agree to  
UpGrad's Terms & Conditions

Our Popular Big Data Course

Frequently Asked Questions (FAQs)

1What are clusters in Cassandra?

A cluster is a group of nodes that together form a single system. Cassandra clusters are one of the shells that make up the Cassandra database as a whole. A cluster is essentially a database's exterior shell or storage unit. Cassandra clusters are made up of many storage levels. Each layer is made up of layers that are themselves made up of layers. The database's primary data source is always a cluster. Users can start the Cluster Builder by issuing a series of instructions. It enables users to do a variety of detailed actions on a cluster as it is being created.

2What makes the Gossip protocol important in Cassandra?

In Cassandra, the Gossip Protocol is a peer-to-peer communication protocol that allows nodes to select whom they wish to share their state information with. The nodes share information regarding themselves and the other nodes about whom they have gossiped or communicated, allowing all nodes in the cluster to learn very quickly about each other. In the Gossip protocol, the technique of acknowledging messages aids in failure detection. Because a node can't transmit or receive information when it is down or failing, acknowledgements are not accepted.

3What are the benefits of Cassandra?

Cassandra has several advantages. To begin with, the most significant benefit of using Apache Cassandra is its elastic scalability, which allows a large number of servers to be added and the cluster to be scaled up and down as needed. Second, because Cassandra is an Apache software, it is open source, which means it is absolutely free to use. For execution, Cassandra uses a peer-to-peer architecture, which implies that all servers are on the same level, and any computer may respond to a client request. As a result, there are only a few opportunities for failure. It encrypts the data and distributes it across different servers. If one server goes down or is hacked, the user may easily get the data from another location.

Explore Free Courses

Suggested Blogs

Top 10 Hadoop Commands [With Usages]
11946
In this era, with huge chunks of data, it becomes essential to deal with them. The data springing from organizations with growing customers is way lar
Read More

by Rohit Sharma

12 Apr 2024

Characteristics of Big Data: Types & 5V’s
5745
Introduction The world around is changing rapidly, we live a data-driven age now. Data is everywhere, from your social media comments, posts, and lik
Read More

by Rohit Sharma

04 Mar 2024

50 Must Know Big Data Interview Questions and Answers 2024: For Freshers & Experienced
7306
Introduction The demand for potential candidates is increasing rapidly in the big data technologies field. There are plenty of opportunities in this
Read More

by Mohit Soni

What is Big Data – Characteristics, Types, Benefits & Examples
185811
Lately the term ‘Big Data’ has been under the limelight, but not many people know what is big data. Businesses, governmental institutions, HCPs (Healt
Read More

by Abhinav Rai

18 Feb 2024

Cassandra vs MongoDB: Difference Between Cassandra & MongoDB [2023]
5468
Introduction Cassandra and MongoDB are among the most famous NoSQL databases used by large to small enterprises and can be relied upon for scalabilit
Read More

by Rohit Sharma

31 Jan 2024

13 Ultimate Big Data Project Ideas & Topics for Beginners [2024]
100333
Big Data Project Ideas Big Data is an exciting subject. It helps you find patterns and results you wouldn’t have noticed otherwise. This skill
Read More

by upGrad

16 Jan 2024

Be A Big Data Analyst – Skills, Salary & Job Description
899709
In an era dominated by Big Data, one cannot imagine that the skill set and expertise of traditional Data Analysts are enough to handle the complexitie
Read More

by upGrad

16 Dec 2023

12 Exciting Hadoop Project Ideas & Topics For Beginners [2024]
20848
Hadoop Project Ideas & Topics Today, big data technologies power diverse sectors, from banking and finance, IT and telecommunication, to manufact
Read More

by Rohit Sharma

29 Nov 2023

Top 10 Exciting Data Engineering Projects & Ideas For Beginners [2024]
40146
Data engineering is an exciting and rapidly growing field that focuses on building, maintaining, and improving the systems that collect, store, proces
Read More

by Rohit Sharma

21 Sep 2023

Schedule 1:1 free counsellingTalk to Career Expert
icon
footer sticky close icon