Gossip Protocol in Cassandra is a peer-to-peer communication protocol in which nodes can choose among themselves with whom they want to exchange their state information. The nodes exchange information about themselves and about the other nodes that they have gossiped about, so all nodes quickly learn about all other nodes in the cluster.
* The Drop table command drops specified table including all the data from the keyspace.
* The Truncate table command is used to truncate a table and deletes all the rows of the table permanently.
* A Static Table uses a relatively static set of column names and is similar to Relational Database Table.
* A dynamic table allows you to pre-compute result sets and stores them in a single row for efficient data retrieval.
In the Single Primary Key, there is only a single column as a Primary Key.
The column is also called partitioning key. Data is partitioned on the basis of that column. Data is spread on different nodes on the basis of the partition key.
* In Compound Primary Key, data is partitioned and then clustered
* race_name is the partitioning key and race_position is the Clustering key. Data will be partitioned on the basis of race_name and data will be clustered on the basis of race_position. Clustering is the process that sorts data in the partition. Retrieval of rows is very efficient when rows for a partition key are stored in order, based on the clustering column.
* Composite partitioning key is used to create multiple partitions for the data
Cassandra CQL collections help you to store multiple values in a single variable. In Cassandra, you can use CQL collections in following ways
List: It is used when the order of the data needs to be maintained, and a value is to be stored multiple times (holds the list of unique elements)
SET: It is used for group of elements to store and returned in sorted orders (holds repeating elements)
MAP: It is a data type used to store a key-value pair of elements
While adding a column you need to take care that the
* Column name is not conflicting with the existing column names
* Table is not defined with compact storage option
A row is a collection of sorted columns. It is the smallest unit that stores related data in Cassandra. Any component of a Row can store data or metadata
The different elements/parts of a row are the
* Row Key
* Column Keys
* Column Values
This is used when we deploy a cluster across Multiple Datacenters. It is the primary consideration to insert replicas. Can satisfy reads, locally without incurring cross Data-Center Latency and also Handle Failure Scenarios.
The main objective of Cassandra is to handle a large amount of data. Furthermore, the objective also ensures fault tolerance with the swift transfer of data.
Avinash Lakshman and Prashant Malik developed Cassandra using Java. Later Apache took it under it for further development.
These are the advantages if Cassandra:
Since data can be replicated to several nodes, Cassandra is fault tolerant.
Cassandra can handle a large set of data.
Cassandra provides high scalability.
Cassandra query language is used for Cassandra Database. It is an interface that a user uses to access the database. It basically is a communication medium. All the operations are carried out from this panel.
The replica placement strategy refers to how the replicas will be placed in the ring
There are different strategies that ship with Cassandra for determining which nodes will get copies of which keys
There are mainly two types of Strategies:
* Simple Strategy
* Network Topology Strategy
Cassandra stores copies (called replicas) of each row based on the row key. The replication factor refers to the number of nodes that will act as copies (replicas) of each row of data.
A keyspace contains many column families. They basically represent the table. Furthermore, it basically defines titles or application specific tables.
While creating a table primary key is mandatory, it is made up of one or more columns of a table.
There are various Cqlsh shell commands in Cassandra. Command “Captureâ€, captures the output of a command and adds it to a file while, command “Consistency†display the current consistency level or set a new consistency level.
Cassandra-Cqlsh is a query language that enables users to communicate with its database. By using Cassandra cqlsh, you can do following things
Define a schema
Insert a data and
Execute a query
ALTER KEYSPACE can be used to change properties such as the number of replicas and the durable_write of a keyspace.
Syntax for creating keyspace in Cassandra is
CREATE KEYSPACE <identifier> WITH <properties>
A data center is a collection of Cassandra nodes. The data in a data center is stored in the form of a cluster, where the cluster is also referred to as a collection of nodes.
A node is a basic unit of Cassandra, and it is a system that is part of a cluster. Node is the main area where the data is stored.
And the units of a node is represented as computer/server
There are various components of Cassandra. While a node is a single machine running Cassandra, cluster is a collection of nodes that have similar types of data grouped together. Data centers are useful components when serving customers in different geographical areas. You can group different nodes of a cluster into different data centers.
With a strong requirement to scale systems when additional resources are needed, CAP Theorem plays a major role in maintaining the scaling strategy. It is an efficient way to handle scaling in distributed systems. Consistency, availability, and partition tolerance (CAP) theorem states that in distributed systems like Cassandra, users can enjoy only two out of these three characteristics.
One of them needs to be sacrificed. Consistency guarantees the return of most recent write for the client; availability returns a rational response within minimum time; and in partition tolerance, the system will continue its operations when network partitions occur. The two options available are AP and CP.
Associated with SSTable, Bloom filter is an off-heap (off the Java heap to native memory) data structure to check whether there is any data available in the SSTable before performing any I/O disk operation.
SSTable expands to ‘Sorted String Table,’ which refers to an important data file in Cassandra and accepts regular written memtables. They are stored on disk and exist for each Cassandra table. Exhibiting immutability, SSTables do not allow any further addition and removal of data items once written. For each SSTable, Cassandra creates three separate files like partition index, partition summary, and a bloom filter.
DataStax OpsCenter: It is the Internet-based management and monitoring solution for Cassandra cluster and DataStax. It is free to download and includes an additional edition of OpsCenter.
SPM primarily administers Cassandra metrics and various OS and JVM metrics. Besides Cassandra, SPM also monitors Hadoop, Spark, Solr, Storm, ZooKeeper, and other Big Data platforms. The main features of SPM include correlation of events and metrics, distributed transaction tracing, creating real-time graphs with zooming, anomaly detection, and heartbeat alerting.
A keyspace is the outermost container for data in Cassandra. Like a relational database, a keyspace has a name and a set of attributes that define keyspace-wide behaviour. The keyspace is used to group Column families together.
Cassandra performs the write function by applying two commits: first, it writes to a commit log on the disk, and then it commits to an in-memory structure known as memtable. Once the two commits are successful, the write is achieved. Writes are written in the table structure as SSTables (sorted string tables). Cassandra offers faster write performance.
Tunable consistency is a phenomenal character that makes Cassandra a favored database choice of Developers, Analysts, and Big data Architects. Consistency refers to the up-to-date and synchronized data rows on all their replicas. Cassandra’s tunable consistency allows users to select the consistency level best suited for their use cases. It supports two consistencies: eventual consistency and strong consistency.
The former guarantees consistency when no new updates are made on a given data item, i.e., all accesses return the last updated value eventually. Systems with eventual consistency are known to have achieved replica convergence.
For strong consistency, Cassandra supports the following condition:
R + W > N where,
N – Number of replicas
W – Number of nodes that need to agree for a successful write
R – Number of nodes that need to agree for a successful read
Column family in Cassandra is referred for a collection of Rows.
The main components of Cassandra Data Model are
* Cluster
* Keyspace
* Column
* Column & Family
* All data stored as bytes
* When you specify validator, Cassandra ensures those bytes are encoded as per requirement
* Then a comparator orders the column based on the ordering specific to the encoding
* While composite are just byte arrays with a specific encoding, for each component it stores a two byte length followed by the byte encoded component followed by a termination bit.
The cassandra.yaml file is the main configuration file for Cassandra. After changing properties in the cassandra.yaml file, you must restart the node for the changes to take effect.
Cassandra-Cqlsh is a query language that enables users to communicate with its database. By using Cassandra cqlsh, you can do following things:
* Define a schema
* Insert a data, and
* Execute a query
There are majorly 3 types/stages of Data Model
* Conceptual Data Model
* Logical Data Model
* Physical Data Model
The type of NoSQL database in which a flexible graphical representation is used. The key purpose is to store relationships between nodes.
Data is stored in cells are grouped in columns of data rather than as rows of data. Columns are logically grouped into column families.
One row may have one or multiple data records, which is indexed by a partition key.
All of the data within database consists of an indexed key and a value. A key may correspond to one or multiple values (hash table). Provides a great performance and can be very easily scaled as per business needs.
This database supports two main categories of functions:
Scalar functions: Its primary purpose is taking some groups of values and producing an output with it.
Aggregate functions: Its primary function is producing a combined result using selected multiple rows.
The components of Cassandra include:
* Node
* Data cluster
* Commit log
* Cluster
* Meme-table
* SSTable
* Bloom filter
Cassandra has become famous for its outstanding technical features. Here are some features you must know:
* Elastic scalability
* Always on architecture
* Fast linear and scale performance
* Flexible in data storage
* Easy to do data distribution
* Excellent transaction support.
Cassandra has become the primary choice for many companies when it comes to app development and data management. Even new start-ups are preferring it because of the ease with which an operator can work.
Cassandra is a great application where data is collected at high speed from different kinds of sources. As the internet of things application could use Cassandra. It could also be used in product and retail apps, messaging, social media analytics, and even by a recommendation engine.
Cassandra has features that are very beneficial as it is easy to work with; Some of those are high performance, fault tolerance, predictable scaling, distributed database. It has high scores on these parameters, and it is also preferred because it is an open-source distributed and NoSQL database management system.
Cassandra is an open-source, distributed, and decentralized database. It is also used for managing a large amount of structured data which is spread out everywhere.
In Cassandra, composite type allows to define key or a column name with a concatenation of data of different type. You can use two types of Composite Type
* Row Key
* Column Name
Cassandra was designed to handle big data workloads across multiple nodes without any single point of failure. The various factors responsible for using Cassandra are
* It is fault tolerant and consistent
* Gigabytes to petabytes scalabilities
* It is a column-oriented database
* No single point of failure
* No need for separate caching layer
* Flexible schema design
* It has flexible data storage, easy data distribution, and fast writes
* It supports ACID (Atomicity, Consistency, Isolation, and Durability)properties
* Multi-data center and cloud capable
* Data compression
These strategies define the technique how the replicas are placed in a cluster. There are mainly two types of Replication Strategy:
Simple strategy
Network Topology Strategy
The data in a node undergoes replication. The data is copied from one node to another to ensure fault tolerance. The replication factor is the number of copies of the data that are sent to different nodes.
Cassandra is a distributed database management system. It is initially developed at Facebook to improve its performance, and it is a tool made to power the Facebook inbox search feature. Due to its outstanding technical features, Cassandra became very popular and a top-level project.