Saturday, 11 January 2014

Apache Cassandra, NO-SQL Databases and CAP Theorem Tutorial

Apache Cassandra is one of the first and most extensively used NoSQL solutions. This article provides concise information on Cassandra without missing out on key points
Cassandra is a non-relational highly scalable, eventually consistent, distributed, structured column family based data store.
Cassandra is a peer to peer architecture where data is distributed among all the nodes. 

What is Cassandra?
  • Originally developed at Facebook organization
  • Written in Java
  • Open-source
  • Name came from Greek Mythology
  • Cassandra uses mixture of concepts from Google's BigTable and Distributed Hash Table (DHT) of Amazon’s Dynamo                                                                                                            
Objectives of learning Cassandra:
  • Promote and validate methodologies that will provide increased market power to low level consumers, through consumer coalitions (Customer social networks – CSN).
Cassandra highlights
  • High availability
  • Incremental scalability
  • Eventually consistent
  • Tunable tradeoffs between consistency and latency
  • Minimal administration
  • No SPF (Single Point of Failure) 

Now, let’s discuss, what has changed with introduction of NoSQL?
  • Massive data volumes
  • Extreme query load
  • Flexible schema evolution- schema never gets fixed and it gets evolved
  • Schema changes can be gradually introduced in the system.

Why are we using Cassandra?

 
When data becomes so big like hundreds of Terabytes, RDBMS breaks. To do Random access two activities has to happen – Seek & Transfer, because of this activity RDBMS was able to do much powerful tasks and became popular.


Cassandra falls under the Columnar or extensible record category where each key is associated with many associates. It still uses tables but have no joins.  Cassandra stores data according to the column family data model.


Cassandra stores data by columns, not like traditional row oriented databases.
Cassandra has a concept called Tunable consistency model, this is the only database that has this particular concept, so you can setup Cassandra either for availability or consistency, Cassandra can work in both the modes unlike other databases. 


We can’t build banking or financial systems using Cassandra instead it is used in social media.
OLTP or payment models can’t be used in Cassandra.

What is CAP Theorem?

 
It is also knows as Brewer’s theorem, states that it is impossible for a distributed computer system to simultaneously provide all three of the following guarantees:
  • Consistency (all nodes see the same data at the same time)
  • Availability (a guarantee that every request receives a response about whether it was successful or failed)
  • Partition Tolerance (the system continues to operate despite arbitrary message loss)
According to this theorem, a distributed system can satisfy any two of these guarantee at the same time, but not all three.

So, we need to understand that partitioning is unavoidable when a network partition fails, i.e. systems can’t communicate with each other, in that particular point, the system should be operational but while it is operational whether it has to hold on availability or hold on to consistency is what each distributed system has to decide.


If you look at the diagram below, it is very clear that Cassandra falls under the category of Available & tolerant partition.

http://intellipaat.com/big-data-hadoop/
Data Modeling in Cassandra
  • Dynamic Schema
  • Column Oriented
  • No Need to have a data model created upfront like we don with RDBMS
  • Each row need not have all the columns like RDBMS
  • Application at runtime can add new columns 
Don’t think of a relational table think of a nested, sorted map data structure.
SortedMap < RowKey, SortedMap<ColumnKey, ColumnValue>>

How to do Logging with Cassandra?

Cassandra can be a log synch and to do this we could integrate with multiple log synch
  • Flume
  • Scribe

These positive points make it easy to recommend Cassandra, but it is essential for a developer to explore the details and tricky points of Cassandra to grasp the complexities of this program.

Learning Apache Cassandra – Intellipaat is market leader in providing online Cassandra Training across the globe. Trained more than 20000 professionals on Big data training and online Hadoop training. Online Cassandra Tutorial at Intellipaat has advantages like you will getting recorded session of previous batch as soon as enrolled and all the sessions will be recorded for which you will have life time access.Trainers training on online Apache Cassandra training are Industry architects having 18 yrs of experience.