You are previewing Apache Cassandra Essentials.
O'Reilly logo
Apache Cassandra Essentials

Book Description

Create your own massively scalable Cassandra database with highly responsive database queries

About This Book

  • Create a Cassandra cluster and tweak its configuration to get the best performance based on your environment

  • Analyze the key concepts and architecture of Cassandra, which are essential to create highly responsive Cassandra databases

  • A fast-paced and step-by-step guide on handling huge amount of data and getting the best out of your database applications

  • Who This Book Is For

    If you are a developer who is working with Cassandra and you want to deep dive into the core concepts and understand Cassandra’s non-relational nature, then this book is for you. A basic understanding of Cassandra is expected.

    What You Will Learn

  • Install and set up your Cassandra Cluster using various installation types

  • Use Cassandra Query Language (CQL) to design Cassandra database and tables with various configuration options

  • Design your Cassandra database to be evenly loaded with the lowest read/write latencies

  • Employ the available Cassandra tools to monitor and maintain a Cassandra cluster

  • Debug CQL queries to discover why they are performing relatively slowly

  • Choose the best-suited compaction strategy for your database based on your usage pattern

  • Tune Cassandra based on your deployment operation system environment

  • In Detail

    Apache Cassandra Essentials takes you step-by-step from from the basics of installation to advanced installation options and database design techniques. It gives you all the information you need to effectively design a well distributed and high performance database. You’ll get to know about the steps that are performed by a Cassandra node when you execute a read/write query, which is essential to properly maintain of a Cassandra cluster and to debug any issues. Next, you’ll discover how to integrate a Cassandra driver in your applications and perform read/write operations. Finally, you’ll learn about the various tools provided by Cassandra for serviceability aspects such as logging, metrics, backup, and recovery.

    Style and approach

    This step-by-step guide is packed with examples that explain the core concepts as well as advanced concepts, techniques, and usages of Apache Cassandra.

    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 If you purchased this book elsewhere, you can visit and register to have the code file.

    Table of Contents

    1. Apache Cassandra Essentials
      1. Table of Contents
      2. Apache Cassandra Essentials
      3. Credits
      4. About the Author
      5. About the Reviewers
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Getting Your Cassandra Cluster Ready
        1. Installation
          1. Prerequisites
          2. Compiling Cassandra from source and installing
          3. Installation from a precompiled binary
        2. The installation layout
          1. The directory layout in tarball installations
          2. The directory layout in package-based installation
        3. Configuration files
          1. cassandra.yaml
        4. Running a Cassandra server
          1. Running a Cassandra node
          2. Setting up the cluster
          3. Viewing the cluster status
        5. Summary
      9. 2. An Architectural Overview
        1. Background
        2. Cassandra cluster overview
          1. The Gossip protocol
          2. Failure detection
        3. Data distribution
        4. Replication
        5. SimpleStrategy
        6. NetworkTopologyStrategy
          1. Snitches
        7. Virtual nodes
        8. Adding nodes to our cluster
        9. Create keyspace and column family
        10. Summary
      10. 3. Creating Database and Schema
        1. A database and schema
          1. Keyspace
          2. Column families
            1. Static rows
            2. Wide rows
          3. A primary key
          4. Partition keys and clustering columns
          5. A composite partition key
            1. Multiple clustering columns
            2. Static columns
            3. Modifying a table
        2. Data types
          1. Counters
          2. Collections
            1. Sets
            2. Lists
            3. Map
          3. UDTs
        3. Secondary indexes
        4. Allowing filtering
        5. TTL
        6. Conditional querying
          1. Conditions on a partition key
          2. Conditions on a partition key and clustering columns
          3. Sorting query results
        7. Write operations
        8. Lightweight transactions
        9. Batch statements
        10. Summary
      11. 4. Read and Write – Behind the Scenes
        1. Write operations
          1. CommitLog
          2. Anatomy of Memtable
          3. SSTable explained
          4. SSTable Compaction strategies
            1. Size-tiered compaction
            2. Leveled compaction
            3. DateTiered compaction
        2. Read operations
          1. Reads from row cache
          2. Read operations for row cache miss
            1. Key is in KeyCache
            2. Key search miss both the key cache and the row cache
        3. Delete operations
        4. Data consistency
          1. Read operation
            1. Digest reads
            2. Read repair
              1. Consistency levels
          2. Write operation
            1. Hinted handoff
              1. Consistency levels
        5. Tracing Cassandra queries
        6. Summary
      12. 5. Writing Your Cassandra Client
        1. Connecting to a Cassandra cluster
          1. Driver Connection policies
            1. Load balancing policies
            2. Retry policies
            3. Reconnection policies
        2. Reading and writing to the Cassandra cluster
          1. QueryBuilder
          2. Reading and writing asynchronously
          3. Prepared statements
            1. Example REST service using prepared statement
          4. Batch statements
        3. Mapping API
        4. Tracing Cassandra queries using Java driver
        5. Summary
      13. 6. Monitoring and Tuning a Cassandra Cluster
        1. Monitoring a Cassandra cluster
          1. Use logging for debugging
          2. Monitoring using command-line utilities
            1. nodetool cfstats
            2. nodetool cfhistograms
            3. nodetool netstats
            4. nodetool tpstats
          3. JConsole
          4. Third-party tools
        2. Tuning Cassandra nodes
          1. Configuring Cassandra caches
          2. Tuning Bloom filters
          3. Configuring and tuning Java
        3. Summary
      14. 7. Backup and Restore
        1. Taking backup of a Casandra cluster
          1. Manual backup
            1. Deleting snapshots
          2. Incremental backup
        2. Restoring data to Cassandra
          1. The Cassandra bulk loader
            1. Exporting and importing data using the Cassandra JSON utility
            2. Loading external data into Cassandra
        3. Removing nodes from Cassandra cluster
        4. Adding nodes to a Cassandra cluster
        5. Replacing dead nodes in a cluster
        6. Summary
      15. Index