Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Cassandra 3.x High Availability
Cassandra 3.x High Availability

Cassandra 3.x High Availability: Achieve scalability and high availability without compromising on performance , Second Edition

eBook
$20.98 $29.99
Paperback
$38.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Cassandra 3.x High Availability

Chapter 2.  Data Distribution

Cassandra's peer-to-peer architecture and scalability characteristics are directly tied to its data placement scheme. Cassandra employs a distributed hash table data structure that allows for data to be stored and retrieved by key quickly and efficiently. Consistent hashing is at the core of this strategy, as it enables all nodes to understand where data exists in the cluster without complicated coordination mechanisms.

In this chapter, we'll cover the following topics:

  • The fundamentals of distributed hash tables
  • Cassandra's consistent hashing mechanism
  • Token assignment, both manual and using vnodes
  • The implications of Cassandra's partitioner implementations
  • How hotspots form in the cluster 

By the time you finish this chapter, you should have a deep understanding of these concepts. Let us begin with some basics about hash tables in general, and then we can delve deeper into Cassandra's distributed hash table implementation...

Hash table fundamentals

Most developers have experience with hash tables in some form, as nearly all programming languages include hash table implementations. Hash tables store data by applying a hash function to the object, which determines its placement in an underlying array.

While a detailed description of hashing algorithms is out of the scope of this book, it is sufficient for you to understand that a hash function simply maps any input data object (which may be any size) to some expected output. While the input may be large, the output of the hash function will be a fixed number of bits.

In a typical hash table design, the result of the hash function is divided by the number of array slots; the remainder then becomes the assigned slot number. Thus, the slot can be computed using hash(o) % n , where o is the object and n is the number of slots. Consider the following hash table, with names as keys and addresses as values:

Hash table fundamentals
The values in the table on the left represent keys, which are...

Consistent hashing

The solution is consistent hashing. Introduced as a term in 1997, consistent hashing was originally used as a means of routing requests among a large number of web servers. It's easy to see how the web could benefit from a hash mechanism that allows any node in the network to efficiently determine the location of an object, in spite of the constant shifting of nodes in and out of the network. This is the fundamental objective of consistent hashing.

How it works

With consistent hashing, the buckets are arranged in a ring with a predefined range. The exact range depends on the partitioner being used. Keys are then hashed to produce a value that lies somewhere along the ring. Nodes are assigned a range, which is computed as follows:

Range start

Token value

Range end

Next token value -1

Tip

The following examples assume the default Murmur3Partitioner is used. For more information on this partitioner, take a look at the documentation, which can be found here: http...

Token assignment

In Cassandra terminology, the start of the hash range is called a token, and until version 1.2, each node was assigned a single token, in the manner discussed in the previous section. Version 1.2 introduced the option to use virtual nodes, or vnodes as the feature is officially termed. Vnodes became the default option in the 2.0 release.

Cassandra determines where to place data by using the tokens assigned to each node. Nodes learn about these token assignments via gossip. Additional replicas are then placed based on the configured replication strategy and snitch. More details about replica placement can be found in Chapter 3, Replication.

Manually assigned tokens

If you have chosen not to use vnodes, you have the requirement to assign tokens manually. This is accomplished by setting the initial_token setting in cassandra.yaml.

Manual token assignment introduces a number of potential issues:

  • Adding and removing nodes:When the size of the ring changes, all tokens must be recomputed...

Partitioners

You may recall from the earlier discussion of distributed hash tables that keys are mapped to nodes via an implementation-specific hash function. In Cassandra's architecture, this function is determined by the partitioner you choose. This is a cluster-wide setting specified in cassandra.yaml. As of version 1.2, there are three options:

  • Murmur3Partitioner (org.apache.cassandra.dht.Murmur3Partitioner): Produces an even distribution of data across the cluster using the Murmur3 hash algorithm. This is the default as of version 1.2, and should not be changed as it is measurably faster than the RandomPartitioner.
  • RandomPartitioner (org.apache.cassandra.dht.RandomPartitioner): Similar to the Murmur3Partitioner, except that it computes an MD5 hash. This was the default prior to version 1.2.
  • ByteOrderedPartitioner (org.apache.cassandra.dht.ByteOrderedPartitioner): Places keys in byte order (lexically) around the ring. This partitioner should generally be avoided for reasons explained...

Summary

At this point, you should have a strong grasp of Cassandra's data distribution architecture, including consistent hashing, tokens, vnodes, and partitioners, as well as some of the causes of data hotspots. Your understanding of these fundamentals should help you to make sound design decisions that enable you to scale your cluster effectively and get the most out of your infrastructure investment.

In this chapter and the previous one, we've made reference a number of times to replication and its related concepts. In our next chapter, we'll discuss replication in depth, as replication is very important in determining the availability of data.

Left arrow icon Right arrow icon

Key benefits

  • See how to get 100 percent uptime with your Cassandra applications using this easy-follow guide
  • Learn how to avoid common and not-so-common mistakes while working with Cassandra using this highly practical guide
  • Get familiar with the intricacies of working with Cassandra for high availability in your work environment with this go-to-guide

Description

Apache Cassandra is a massively scalable, peer-to-peer database designed for 100 percent uptime, with deployments in the tens of thousands of nodes, all supporting petabytes of data. This book offers a practical insight into building highly available, real-world applications using Apache Cassandra. The book starts with the fundamentals, helping you to understand how Apache Cassandra’s architecture allows it to achieve 100 percent uptime when other systems struggle to do so. You’ll get an excellent understanding of data distribution, replication, and Cassandra’s highly tunable consistency model. Then we take an in-depth look at Cassandra's robust support for multiple data centers, and you’ll see how to scale out a cluster. Next, the book explores the domain of application design, with chapters discussing the native driver and data modeling. Lastly, you’ll find out how to steer clear of common anti-patterns and take advantage of Cassandra’s ability to fail gracefully.

Who is this book for?

If you are a developer or DevOps engineer who has basic familiarity with Cassandra and you want to become an expert at creating highly available, fault tolerant systems using Cassandra, this book is for you.

What you will learn

  • Understand how the core architecture of Cassandra enables highly available applications
  • Use replication and tunable consistency levels to balance consistency, availability, and performance
  • Set up multiple data centers to enable failover, load balancing, and geographic distribution
  • Add capacity to your cluster with zero downtime
  • Take advantage of high availability features in the native driver
  • Create data models that scale well and maximize availability
  • Understand common anti-patterns so you can avoid them
  • Keep your system working well even during failure scenarios

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Aug 29, 2016
Length: 196 pages
Edition : 2nd
Language : English
ISBN-13 : 9781786462107
Vendor :
Apple
Category :
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Aug 29, 2016
Length: 196 pages
Edition : 2nd
Language : English
ISBN-13 : 9781786462107
Vendor :
Apple
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 126.97
Cassandra 3.x High Availability
$38.99
Learning Apache Cassandra
$48.99
Cassandra Design Patterns
$38.99
Total $ 126.97 Stars icon

Table of Contents

9 Chapters
1. Cassandras Approach to High Availability Chevron down icon Chevron up icon
2. Data Distribution Chevron down icon Chevron up icon
3. Replication Chevron down icon Chevron up icon
4. Data Centers Chevron down icon Chevron up icon
5. Scaling Out Chevron down icon Chevron up icon
6. High Availability Features in the Native Java Client Chevron down icon Chevron up icon
7. Modeling for Availability Chevron down icon Chevron up icon
8. Anti-Patterns Chevron down icon Chevron up icon
9. Failing Gracefully Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.8
(6 Ratings)
5 star 50%
4 star 16.7%
3 star 16.7%
2 star 0%
1 star 16.7%
Filter icon Filter
Top Reviews

Filter reviews by




BJORN Apr 17, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I just started learning about Cassandra, and this book was a great help, I have about 10 years experience in networkings and linux and thought this was a good source of information to help you start designing and building your next Cassandra cluster. It also gives a good overview of how things work internally and how to setup clusters in multiple datacenters.
Amazon Verified review Amazon
Amazon Customer Sep 29, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I am about to deploy a production Cassandra cluster to AWS to back a mobile app and this book helps tremendously.
Amazon Verified review Amazon
Paul Rafferty Nov 23, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Must have reference for Cassandra 3.0 high availability.
Amazon Verified review Amazon
Rahul Dec 01, 2016
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Good
Amazon Verified review Amazon
Amazon Customer Oct 15, 2017
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
Not bad, but not good. Definitive guide include more information. This book has less
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.