Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Cassandra DBA Best Practices for Ops Teams

· 5 min read · Home Tech

In this article
  1. Capacity Planning and Sizing
  2. Backup and Restore Strategy
  3. Compaction and Repair Tuning
  4. Monitoring and Alerting
  5. Common Pitfalls and How to Avoid Them
  6. Frequently Asked Questions

This article answers the question directly: the best practices for a Cassandra administrator or DBA team center on capacity planning, consistent backup/restore drills, compaction and repair tuning, and proactive monitoring. You’ll get the operational checklist that keeps a cluster healthy, plus the reasoning behind each practice so you can adapt it to your own workloads.

Capacity Planning and Sizing

Before you even install Cassandra, the most important DBA task is capacity planning. You need to know how much data you have, how fast it grows, and how many replicas you need.

Key planning factors:

  • Compaction strategy: SizeTieredCompactionStrategy (STCS) requires up to 50% extra disk during major compactions; LeveledCompactionStrategy (LCS) uses less temporary space but more IO.
  • Bloom filters: These are stored in memory and can take 1–2 GB per billion partitions. Plan RAM accordingly.
  • Commit log: Separate commit log disk from data disk to avoid IO contention.
  • Growth rate: Always plan for at least 12–18 months of growth, not just today’s size.

A common mistake is to size nodes based on the current data size and then run out of disk after a few months. Re-evaluate capacity quarterly.

Backup and Restore Strategy

Cassandra’s distributed nature means backups are not a simple file copy. You need to coordinate backups across all nodes. The standard approach is to use nodetool snapshot on each node, which creates hard links to SSTable files. Then you copy those files to a separate storage system.

Best practices for backups:

  • Take snapshots on all nodes at the same time to get a consistent cluster-wide backup.
  • Back up the schema (using cqlsh or DESCRIBE SCHEMA) separately, because schema changes are not captured in snapshots.
  • Store backups off-cluster (e.g., object storage) and test restoration regularly.
  • Use incremental backups (incremental_backups=true) if you need point-in-time recovery, but be aware they increase disk usage.

Restore drills are non-negotiable. A backup that has never been restored is not a backup. At least once a quarter, restore a subset of data to a test cluster and verify integrity.

Compaction and Repair Tuning

Compaction is the process of merging SSTables to reclaim space and improve read performance. Repair ensures that all replicas have the same data. Both are essential but can hurt performance if not tuned.

Compaction tips:

  • Choose the right strategy for your workload: STCS for write-heavy, LCS for read-heavy or update-heavy workloads.
  • Monitor compaction backlog via nodetool compactionstats. If pending tasks grow, reduce write load or add nodes.
  • Schedule major compactions during low-traffic windows if using STCS.

Repair tips:

  • Run incremental repairs regularly (default is 10 days, but many teams run weekly).
  • Use nodetool repair -pr (primary range) to repair only the ranges a node owns, reducing load.
  • Monitor repair progress and ensure it completes before the next repair window.

Ignoring repairs leads to data inconsistency that can surface as missing or stale reads. Make repair part of your routine maintenance.

Monitoring and Alerting

You cannot manage what you don’t measure. A Cassandra DBA team needs visibility into both cluster health and performance. Key metrics to track:

  • CPU and load: Sustained high CPU may indicate compaction or heavy queries.
  • Disk usage and IO: Watch for disk filling up; Cassandra will crash if it runs out of space.
  • Memory (heap and off-heap): Ensure heap usage stays below 70% to avoid GC pauses.
  • Latency percentiles: Track p99 read/write latencies per table.
  • Compaction and repair status: Alert on pending compactions or failed repairs.
  • Gossip and failure detection: Unreachable nodes can cause availability issues.

Use tools like Prometheus with the Cassandra exporter, or DataStax Enterprise’s monitoring, but the key is to set alerts that fire before problems become outages. For example, alert when disk usage exceeds 70% or when p99 latency doubles.

Common Pitfalls and How to Avoid Them

Even experienced teams make mistakes. Here are the most common ones and how to avoid them:

  • Using default settings without review: Defaults are for development, not production. Tune concurrent_reads, concurrent_writes, and heap size.
  • Ignoring tombstone accumulation: Too many tombstones can cause read timeouts. Monitor tombstone_scanned metrics and adjust TTL or compaction.
  • Running repairs during peak hours: Repairs consume significant IO. Schedule them off-peak.
  • Not testing failover: Kill a node in a test environment to see if your application handles it gracefully.
  • Overusing ALLOW FILTERING: This can cause full-table scans. Design queries around primary keys.

Document your operational runbooks and review them after any incident.

Frequently Asked Questions

How often should I run repair?

Incremental repairs should run at least once per gc_grace_seconds (default 10 days) to prevent data resurrection. Many production teams run them weekly to reduce the risk of inconsistency. Full repairs are rarely needed if incremental repairs are regular.

What is the best compaction strategy for a write-heavy workload?

SizeTieredCompactionStrategy (STCS) is generally best for write-heavy workloads because it minimizes write amplification. However, if you also do many updates or deletes, LeveledCompactionStrategy (LCS) may give better read performance and disk space usage, at the cost of higher IO.

How do I know when to add nodes?

Monitor disk usage, latency, and compaction backlog. If disk usage consistently exceeds 70% or p99 latency degrades, add nodes.

Can I use RAID for Cassandra data disks?

Yes, but avoid RAID 5/6 due to write performance. RAID 10 is a good choice for both performance and redundancy. However, Cassandra already replicates data across nodes, so many teams skip RAID and use JBOD with a replication factor of 3.

What is the difference between a snapshot and a backup?

A snapshot is a point-in-time hard-link copy of SSTables on the local node. It is not a backup unless you copy those files to external storage. A backup includes the snapshot files plus the schema and configuration. Always copy snapshots off-node.

How do I handle a node that is down for a long time?

If a node is down longer than max_hint_window_in_ms (default 3 hours), hints expire and the node will need a full repair to catch up. In that case, run nodetool repair on that node after it comes back, or consider replacing it if it’s unrecoverable.