Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Apache Cassandra

You're reading from   Learning Apache Cassandra Managing fault-tolerant, scalable data with high performance

Arrow left icon
Product type Paperback
Published in Apr 2017
Publisher
ISBN-13 9781787127296
Length 360 pages
Edition 2nd Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Sandeep Yarabarla Sandeep Yarabarla
Author Profile Icon Sandeep Yarabarla
Sandeep Yarabarla
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Getting Up and Running with Cassandra FREE CHAPTER 2. The First Table 3. Organizing Related Data 4. Beyond Key-Value Lookup 5. Establishing Relationships 6. Denormalizing Data for Maximum Performance 7. Expanding Your Data Model 8. Collections, Tuples, and User-Defined Types 9. Aggregating Time-Series Data 10. How Cassandra Distributes Data 11. Cassandra Multi-Node Cluster 12. Application Development Using the Java Driver 13. Peeking under the Hood 14. Authentication and Authorization

MapReduce and Spark

MapReduce is a technique for performing aggregate processing on large amounts of data in parallel; it's a particularly common technique in data analytics applications. Cassandra does not offer built-in MapReduce capabilities, but it can be integrated with Hadoop in order to perform MapReduce operations across Cassandra data sets, or Spark for real-time data analysis. The DataStax enterprise product provides integration with both of these tools out of the box.
Spark is a fast, distributed, and expressive computational engine used for large-scale data processing similar to MapReduce. It is much more efficient than MapReduce and runs with resource managers such as Mesos and Yarn. It can read data from various sources such as Hadoop or Cassandra or even streams such as Kafka. DataStax provides a Spark-Cassandra connector to load data from Cassandra into Spark and run batch computations on the data.

Rich and flexible data model

Cassandra provides an SQL-like syntax to interact with the database. Cassandra Query Language (CQL) presents a familiar row column representation of data. CQL provides a familiar SQL-like table definition with columns and defined data types. Schema is flexible, and new columns can be added while using the existing data. The data model doesn't support features problematic in distributed systems such as joins. On top of this, Cassandra provides other features such as collections to store multiple items in a single column. It also lets you easily define secondary indexes and materialized views for fast lookups on non-primary key columns.

The previous thrift-based interface was closely tied to the internal storage view. This was fairly complex and had a relatively high learning curve to adopt. The CQL interface is much easier to understand because of its similarity to SQL.

Lightweight transactions

As discussed before, Cassandra provides eventual consistency rather than immediate consistency, which means data written will eventually be consistent across multiple replicas of the data. This has implications on the data returned by read queries. There is a possibility that reads could return stale data depending on how writes and reads are configured (the consistency levels at which both queries are performed). Strong consistency, which means reading the most recently written value, can be achieved using quorum reads and writes. But what if strong consistency is not enough? What if we have some operations to perform in sequence that must not be interrupted by others, that is, we must perform them one at a time, or make sure that any that we do run concurrently get the same results as if they really were processed independently. Cassandra provides lightweight transactions with linearizable consistency to ensure a transaction isolation level similar to the serializable level offered by RDBMSs. They are also known as compare and set transactions. You can use lightweight transactions instead of durable transactions with eventual/tunable consistency for situations that require the nodes in the distribution system to agree on changes to the data.

Multidata center replication

Another interesting feature provided by Cassandra is the ability to replicate data across multiple data centers or geographical zones in near real-time. This is natively supported by Cassandra and doesn't need to be managed at the application level. Cassandra also provides local consistency levels to ensure cross-region latency doesn't impact client queries. A multiregion cluster can sustain disasters or entire data centers going down. Ideally, there is no need for backups or disaster recovery when running multidata center clusters except for cases of data corruption.

On April 21, 2011, Amazon experienced a large outage in AWS US-East. Some websites were impacted, while others were not. For Netflix, their systems are designed explicitly for these sorts of failures. The SimpleDB, S3, and Cassandra services that Netflix depends upon were not affected by the outage because of the cross-region replication that these services provide.

Comparing Cassandra to the alternatives

Now that you've got an in-depth understanding of the feature set that Cassandra offers, it's time to figure out which features are most important to you and which database is the best fit. The following table lists a handful of commonly used databases and key features that they do or don't have:

Feature Cassandra PostgreSQL MongoDB Redis Riak
Structured records Yes Yes Yes Limited No
Secondary indexes Yes Yes Yes No Yes
Discretely writable collections Yes Yes Yes Yes No
Relational joins No Yes No No No
Built-in MapReduce No No Yes No Yes
Fast result ordering Yes Yes Yes Yes No
Immediate consistency Configurable at query level Yes Yes Yes Configurable at cluster level
Transparent sharding Yes No Yes No Yes
No single point of failure Yes No No No Yes
High throughput writes Yes No No Yes Yes

As you can see, Cassandra offers a unique combination of scalability, availability, and a rich set of features for modeling and accessing data.

You have been reading a chapter from
Learning Apache Cassandra - Second Edition
Published in: Apr 2017
Publisher:
ISBN-13: 9781787127296
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image