DataStax Enterprise 3.0 Documentation

Production deployment planning

This section provides guidelines for determining the size of your production Cassandra cluster based on the data you plan to store.

Planning includes the following activities:

Prerequisites

Before starting to plan a production cluster, you need:

  • A good understanding of the size of the raw data you plan to store.
  • A good estimate of your typical application workload.
  • A plan to model your data in Cassandra (number of column families, rows, columns per row, and so on).

Selecting hardware for enterprise implementations

As with any application, choosing appropriate hardware depends on selecting the right balance of the following resources: memory, CPU, disks, number of nodes, and network.

Note

Hadoop and Solr nodes require their own nodes/disks and have specific hardware requirements. See the Hadoop and Solr documentation for more information when determining your capacity requirements.

Memory

The more memory a Cassandra node has, the better read performance. More RAM allows for a larger file system cache and reduces disk I/O for reads. The ideal amount of RAM depends on the anticipated size of your hot data.

DataStax recommends the following memory requirements:

  • For dedicated hardware, a minimum of 8GB of RAM is needed. For most implementations you should use 16GB to 32GB.
  • Java heap space should be set according to Cassandra 1.1 guidelines.
  • For a virtual environment use a minimum of 4GB, such as Amazon EC2 Large instances. For production clusters with a healthy amount of traffic, 8GB is more common.
  • For Solr and Hadoop nodes, use 32GB or more of total RAM.

CPU

Insert-heavy workloads are CPU-bound in Cassandra before becoming memory-bound. Cassandra is highly concurrent and uses as many CPU cores as available.

  • For dedicated hardware, 8-core processors are the current price-performance sweet spot.
  • For virtual environments, consider using a provider that allows CPU bursting, such as Rackspace Cloud Servers.

Disk

What you need for your environment depends a lot on the usage, so it's important to understand the mechanism. Cassandra writes data to disk for two purposes:

  • All data is appended to the commit log for durability.
  • When thresholds are reached, Cassandra periodically flushes in-memory data structures (memtables) to immutable SSTable data files for storage of column family data.

Commit logs receive every write made to a Cassandra node, but are only read during node start up. Commit logs are purged after the corresponding data is flushed. Conversely, SSTable (data file) writes occur asynchronously and are read during client look-ups. Additionally, SSTables are periodically compacted. Compaction improves performance by merging and rewriting data and discarding old data. However, during compaction (or node repair), disk utilization and data directory volume can substantially increase. For this reason, DataStax recommends leaving an adequate amount of free disk space available on a node (50% [worst case] for tiered compaction, 10% for leveled compaction).

Recommendations:

  • DataStax neither supports nor recommends using Network Attached Storage (NAS) because of performances issues, such as network saturation, I/O overload, pending-task swamp, excessive memory usage, and disk contention.

  • When choosing disks, consider both capacity (how much data you plan to store) and I/O (the write/read throughput rate). Most workloads are best served by using less expensive SATA disks and scaling disk capacity and I/O by adding more nodes (with more RAM).

  • Solid-state drives (SSDs) are a valid choice for Cassandra. Cassandra's sequential, streaming write patterns minimize the undesirable effects of write amplification associated with SSDs.

  • Ideally Cassandra needs at least two disks, one for the commit log and the other for the data directories. At a minimum the commit log should be on its own partition.

  • Commit log disk - this disk does not need to be large, but it should be fast enough to receive all of your writes as appends (sequential I/O).

  • Data disks - use one or more disks and make sure they are large enough for the data volume and fast enough to both satisfy reads that are not cached in memory and to keep up with compaction.

  • RAID - the compaction process can temporarily require up to double the normal data directory volume. This means when approaching 50% of disk capacity, you should use RAID 0 or RAID 10 for your data directory volumes. RAID also helps smooth out I/O hotspots within a single SSTable.

    • Use RAID0 if disk capacity is a bottleneck and rely on Cassandra's replication capabilities for disk failure tolerance. If you lose a disk on a node, you can recover lost data through Cassandra's built-in repair.
    • Use a setra setting of 512, especially on Amazon EC2 RAID0 devices. See Optimum blockdev --setra Settings for RAID.
    • Use RAID10 to avoid large repair operations after a single disk failure, or if you have disk capacity to spare.
    • Because data is stored in the memtable, generally RAID is not needed for the commit log disk, but if you need the extra redundancy, use RAID 1.
  • Extended file systems - On ext2 or ext3, the maximum file size is 2TB even using a 64-bit kernel. On ext4 it is 16TB.

    Because Cassandra can use almost half your disk space for a single file, use XFS when raiding large disks together, particularly if using a 32-bit kernel. XFS file size limits are 16TB max on a 32-bit kernel, and essentially unlimited on 64-bit.

Number of nodes

The amount of data on each disk in the array isn't as important as the total size per node. Using a greater number of smaller nodes is better than using fewer larger nodes because of potential bottlenecks on larger nodes during compaction.

Network

Since Cassandra is a distributed data store, it puts load on the network to handle read/write requests and replication of data across nodes. Be sure to choose reliable, redundant network interfaces and make sure that your network can handle traffic between nodes without bottlenecks.

  • Recommended bandwidth is 1000 Mbit/s (Gigabit) or greater.
  • Bind the Thrift interface (listen_address) to a specific NIC (Network Interface Card).
  • Bind the RPC server interface (rpc_address) to another NIC.

Cassandra is efficient at routing requests to replicas that are geographically closest to the coordinator node handling the request. Cassandra will pick a replica in the same rack if possible, and will choose replicas located in the same data center over replicas in a remote data center.

Ports

If using a firewall, make sure that nodes within a cluster can reach each other. See Configuring firewall port access.

Planning an Amazon EC2 cluster

DataStax provides an Amazon Machine Image (AMI) to allow you to quickly deploy a multi-node Cassandra cluster on Amazon EC2. The DataStax AMI initializes all nodes in one availability zone using the SimpleSnitch. If you want an EC2 cluster that spans multiple regions and availability zones, do not use the DataStax AMI. Instead, initialize your EC2 instances for each Cassandra node and then configure the cluster as a multiple data-center cluster.

Use the following guidelines when setting up your cluster:

  • For most production clusters, use or Extra Large instances with local storage.

    Note

    Amazon Web Service recently reduced the number of default ephemeral disks attached to the image from four to two. Performance will be slower for new nodes unless you manually attach the additional two disks; see Amazon EC2 Instance Store.

  • For low to medium data throughput production clusters, use Large instances with local storage (which are generally adequate for about a year).

  • RAID0 the ephemeral disks, and put both the data directory and the commit log on that volume. This has proved to be better in practice than putting the commit log on the root volume (which is also a shared resource).

  • For data redundancy, consider deploying your cluster across multiple availability zones or using EBS volumes to store your backup files.

  • EBS volumes are not recommended for Cassandra data volumes. Their network performance and disk I/O are not good fits for Cassandra for the following reasons:

    • EBS volumes contend directly for network throughput with standard packets. This means that EBS throughput is likely to fail if you saturate a network link.
    • EBS volumes have unreliable performance. I/O performance can be exceptionally slow, causing the system to backload reads and writes until the entire cluster becomes unresponsive.
    • Adding capacity by increasing the number of EBS volumes per host does not scale. You can easily surpass the ability of the system to keep effective buffer caches and concurrently serve requests for all of the data it is responsible for managing.

    For more information and graphs related to ephemeral versus EBS performance, see the blog article at http://blog.scalyr.com/2012/10/16/a-systematic-look-at-ec2-io/.

Calculating usable disk capacity

To calculate how much data your Cassandra nodes can hold, calculate the usable disk capacity per node and then multiply that by the number of nodes in your cluster. Remember that in a production cluster, you will typically have your commit log and data directories on different disks. This calculation is for estimating the usable capacity of the data volume.

Start with the raw capacity of the physical disks:

raw_capacity = disk_size * number_of_disks

Account for file system formatting overhead (roughly 10 percent) and the RAID level you are using. For example, if using RAID-10, the calculation would be:

(raw_capacity * 0.9) / 2 = formatted_disk_space

During normal operations, Cassandra routinely requires disk capacity for compaction and repair operations. For optimal performance and cluster health, DataStax recommends that you do not fill your disks to capacity, but run at 50-80 percent capacity. With this in mind, calculate the usable disk space as follows (example below uses 50%):

formatted_disk_space * 0.5 = usable_disk_space

Calculating User Data Size

Typically in data storage systems, the size of your raw data will be larger once it is loaded into the database due to storage overhead. On average, raw data is about 2 times larger on disk after it is loaded into the Cassandra, but could vary in either direction depending on the characteristics of your data and column families. The calculations in this section account for data persisted to disk, not for data stored in memory.

  • Column Overhead - Every column in Cassandra incurs 15 bytes of overhead. Since each row in a column family can have different column names as well as differing numbers of columns, metadata is stored for each column. For counter columns and expiring columns, add an additional 8 bytes (23 bytes column overhead). So the total size of a regular column is:

    total_column_size = column_name_size + column_value_size + 15
    
  • Row Overhead - Just like columns, every row also incurs some overhead when stored on disk. Every row in Cassandra incurs 23 bytes of overhead.

  • Primary Key Index - Every column family also maintains a primary index of its row keys. Primary index overhead becomes more significant when you have lots of skinny rows. Sizing of the primary row key index can be estimated as follows (in bytes):

    primary_key_index = number_of_rows * (32 + average_key_size)
    
  • Replication Overhead - The replication factor obviously plays a role in how much disk capacity is used. For a replication factor of 1, there is no overhead for replicas (as only one copy of your data is stored in the cluster). If replication factor is greater than 1, then your total data storage requirement will include replication overhead.

    replication_overhead = total_data_size * (replication_factor - 1)