Book Image

Cassandra High Performance Cookbook

By : Edward Capriolo
Book Image

Cassandra High Performance Cookbook

By: Edward Capriolo

Overview of this book

<p>Apache Cassandra is a fault-tolerant, distributed data store which offers linear scalability allowing it to be a storage platform for large high volume websites. <br /><br />This book provides detailed recipes that describe how to use the features of Cassandra and improve its performance. Recipes cover topics ranging from setting up Cassandra for the first time to complex multiple data center installations. The recipe format presents the information in a concise actionable form.<br /><br />The book describes in detail how features of Cassandra can be tuned and what the possible effects of tuning can be. Recipes include how to access data stored in Cassandra and use third party tools to help you out. The book also describes how to monitor and do capacity planning to ensure it is performing at a high level. Towards the end, it takes you through the use of libraries and third party applications with Cassandra and Cassandra integration with Hadoop.</p>
Table of Contents (20 chapters)
Cassandra High Performance Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Apache Cassandra is a fault-tolerant, distributed data store which offers linear scalability allowing it to be a storage platform for large high volume websites.

This book provides detailed recipes that describe how to use the features of Cassandra and improve its performance. Recipes cover topics ranging from setting up Cassandra for the first time to complex multiple data center installations. The recipe format presents the information in a concise actionable form.

The book describes in detail how features of Cassandra can be tuned and what the possible effects of tuning can be. Recipes include how to access data stored in Cassandra and use third party tools to help you out. The book also describes how to monitor and do capacity planning to ensure it is performing at a high level. Towards the end, it takes you through the use of libraries and third-party applications with Cassandra and Cassandra integration with Hadoop.

What this book covers

Chapter 1, Getting Started: The recipes in this chapter provide a whirlwind tour of Cassandra. Setup recipes demonstrate how to download and install Cassandra as a single instance or simulating multiple instance clusters. Trouble-shooting recipes show how to run Cassandra with more debugging information and how to use management tools. Also included are recipes for end users which connect with the command like interface and setup an environment to build code to access Cassandra.

Chapter 2, Command-line Interface: This chapter provides recipes on using Cassandra's command line interface. Recipes cover how the CLI is used to make changes to the metadata such as key spaces, column families, and cache settings. Additionally recipes show how to use the CLI to set, get and scan data.

Chapter 3, Application Programmer Interface: Cassandra provides an application programmer interface for programs to insert and access data. The chapter has recipes for doing common operations like inserting fetching, deleting, and range scanning data. Also covered in this chapter are recipes for batch mutate and multi-get which are useful in batch programs.

Chapter 4, Performance Tuning: Many configuration knobs and tunable settings exist for Cassandra. Additionally hardware choices and operating system level tuning effect performance. The recipes in this chapter show configuration options and how changing them optimizes performance.

Chapter 5, Consistency, Availability, and Partition Tolerance with Cassandra: Cassandra is designed from the ground up to store and replicate data across multiple nodes. This chapter has recipes that utilize tunable consistency levels and configure features like read repair. These recipes demonstrate how to use features of Cassandra that make available even in the case of failures or network partitions.

Chapter 6, Schema Design: The Cassandra data model is designed for storing large amounts of data across many nodes. This chapter has recipes showing how common storage challenges can be satisfied using Cassandra. Recipes include techniques for serializing data, storing large objects, time series, normalized, and de-normalized data.

Chapter 7, Administration and Cluster Management: Cassandra allows nodes to be added and remove from the cluster without downtime. This chapter contains recipes for adding, moving, and removing nodes as well as administrative techniques for backing up and restoring data. Also covered administrative techniques such as backing up or restoring data.

Chapter 8, Multiple Datacenter Deployments: Cassandra is designed to work both when nodes are deployed in a local area network and when nodes are separated by larger geographical distances such as a wide area network. The recipes in this chapter show how to configure and use features that control and optimize how Cassandra works in multiple datacenter environments.

Chapter 9, Coding and Internals: This chapter covers programming recipes that go beyond the typical application programmer interface, including building Cassandra from source, creating custom types for use with Cassandra, and modifying tools like the JSON export tools.

Chapter 10, Third-party Libraries and Applications: A variety of libraries and applications exist for Cassandra. This chapter introduces tools that make coding easier such as the high-level client Hector, ot the object mapping tool Kundera. Recipes also show how to setup and use applications built on top of Cassandra such as the full text search engine solandra.

Chapter 11, Hadoop and Cassanda: Hadoop is a distributed file system, HDFS that provides high throughput and redundant storage and MapReduce, a software framework for distributed processing of large data sets on compute clusters. This chapter provides recipes with tips on setting up Hadoop and Cassandra both individually and on shared hardware. Recipes show how to use Cassandra as the input or output of map reduce jobs, as well as common tasks like counting or joining data that can be done with Cassandra data inside Hadoop.

Chapter 12, Collecting and Analyzing Statistics: This chapter covers techniques for collecting performance data from the Cassandra and the operating system. Recipes collect and display performance data and how to interpret that data and use the information tune Cassandra servers.

Chapter 13, Monitoring: The monitoring chapter has recipes which show how to install and use tools to help understand the performance of Cassandra. Recipes include how to forward log events to a central server for aggregation. Othere recipes show how to monitor logs for dangerous conditions.

What you need for this book

To run the examples in this book the following software will be required:

  • Java SE Development Kit 1.6.0+, 6u24 recommended

  • Apache Cassandra 0.7.0+, 7.5 recommended

  • Apache Ant 1.6.8+

  • Subversion Client 1.6+

  • Maven 3.0.3+

Additionally the following tools are helpful, but are not strictly required:

  • Apache Thrift, latest stable release recommended

  • Apache Hadoop 0.20.0+,0.20.2 recommended (needed for Hadoop Chapter)

  • Apache Hive 0.7.0+, 0.7.0 recommended (needed for Hadoop Chapter)

  • Apache Zookeeper 3.3.0+, 3.3.3 recommended (needed 1 for locking recipe)

Who this book is for

This book is designed for administrators, developers, and data architects who are interested in Apache Cassandra for redundant, highly performing, and scalable data storage. Typically these users should have experience working with a database technology, multiple node computer clusters, and high availability solutions.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "Edit the configuration file conf/cassandra.yaml to set where commit logs will be stored."

A block of code is set as follows:

package hpcas.c03;
import hpcas.c03.*;
import java.util.List;
import org.apache.cassandra.thrift.*;

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

<path id="hpcas.test.classpath">
    <pathelement location="${test.build}"/>
    <pathelement location="${test.conf}" />
    <path refid="hpcas.classpath"/>
  </path>

Any command-line input or output is written as follows:

$ ant test
test:
    [junit] Running Test
    [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.42 sec
    [junit] Running hpcas.c05.EmbeddedCassandraTest
    [junit] All tests complete
    [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 3.26 sec

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Click on the attributes and the Scores information will appear in the right panel."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code for this book

You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.