Cassandra Best Practices: 17 Rules for Data and Ops

Your Cassandra cluster works in testing, then reads slow down, nodetool logs tombstone warnings, or a node restart becomes an outage. These Cassandra best practices cover the 17 choices behind most of those problems, each with what to do, why it helps and how to check it on your own cluster.

Quick answer: model one table per query, keep every partition under about 100 MB and 100,000 values, never filter without the partition key, use TTL instead of deletes, run LOCAL_QUORUM with RF=3 per datacenter on NetworkTopologyStrategy, finish repair inside gc_grace_seconds, pick the compaction strategy on purpose, and test your restores. Examples marked as run used Cassandra 5.0.9.

Diagram comparing one 25.1 MB Cassandra partition holding 200,000 sensor readings with 24 daily partitions of at most 1.1 MB, with the traced read times measured on Cassandra 5.0.9

Cassandra Best Practices at a Glance

A partition is the unit Cassandra stores, replicates, reads, compacts and repairs. Every row with the same partition key lives in one partition on a fixed set of replicas, so most practices below keep that unit small, evenly spread and cheap to read.

Best Practices Summary

  • Data model (1 to 3): one table per query, a high-cardinality partition key, bounded partitions and time buckets.
  • Reads (4 to 6): no ALLOW FILTERING, SAI instead of legacy indexes, small IN lists and batches.
  • Consistency and writes (7 to 10): LOCAL_QUORUM with RF=3, rare lightweight transactions, careful counters and collections, TTL over deletes.
  • Storage and clients (11 to 13): a deliberate compaction strategy, one prepared and token-aware session, authentication and TLS.
  • Operations (14 to 17): repair inside gc_grace_seconds, tested restores, monitored disks and heap, rolling upgrades.

Which Cassandra Version Does This Guide Assume?

Facts were checked on 2026-11-26 against the Apache Cassandra 5.0 documentation and the download page (5.0.9 is the latest GA release, 4.1.12 and 4.0.21 are older lines). Examples marked as run were executed on one local 5.0.9 node (Java 17, cqlsh 6.2.0). Anything that needs several nodes, TLS, authentication or real traffic is labelled not run.

Cassandra Data Modeling Best Practices and Partition Key Design

Design from your queries, not from your entities. For background on modeling in general see data modelling fundamentals for SQL and NoSQL.

1. Model one table per query and denormalize

  • What to do: List the queries first, create one table per query and write to each. Put the sort and range columns after the partition key and set CLUSTERING ORDER BY, then read with a range and LIMIT instead of sorting in code. The official data modeling guide treats duplicated data as normal. Example (run):
  • Why: A query that touches one partition is answered by one set of replicas, and rows inside a partition are stored sorted by the clustering columns, so “newest 100” is a contiguous slice. There are no joins, so the join work is done once at write time.
  • How to check: TRACING ON in cqlsh: the read should show one Executing single-partition query line, and Read N live rows should be close to the rows you asked for.
CREATE TABLE bp.orders_by_customer (
  customer_id uuid,
  order_id    timeuuid,
  status      text,
  total       decimal,
  PRIMARY KEY ((customer_id), order_id)
) WITH CLUSTERING ORDER BY (order_id DESC);

-- A second table, orders_by_id (order_id PRIMARY KEY), serves "find one order by id".

2. Pick a high-cardinality partition key that every query supplies

  • What to do: Use the column your queries always filter by with equality and that has many distinct values, such as customer_id. Avoid country or status as the whole key. If one value is very busy, add a bucket (practice 3).
  • Why: The partition key is hashed to choose replicas. Many distinct keys spread rows and traffic across nodes, and a few distinct keys pile everything on a few nodes.
  • How to check: nodetool tablestats keyspace.table: compare Compacted partition maximum bytes with the mean. A maximum far above the mean marks a hot or oversized key.

3. Keep partitions bounded and bucket time series

  • What to do: Estimate rows times columns per partition before launch. The data modeling intro gives the guideline of below 100,000 values and below 100 MB per partition, and the refining guide states the hard limit of 2 billion cells. For data that grows forever, such as one sensor every few seconds, add a day or hour to the partition key and query bucket by bucket. The partition_size_warn_threshold guardrail in cassandra.yaml (disabled by default) can warn you (not run). Table (run):
  • Why: A partition is read, compacted, repaired and streamed as a unit, so the bigger it is, the more memory and I/O each step needs. Each bucket is a new bounded partition, and old buckets stop receiving writes, which also suits TWCS (practice 11).
  • How to check: nodetool tablehistograms keyspace table (Partition Size and Cell Count columns) and Compacted partition maximum bytes in tablestats, checked again as data grows. A query across several days now needs one query per bucket.
CREATE TABLE bp.readings_bucketed (
  sensor_id    text,
  day_bucket   date,
  reading_time timestamp,
  payload      text,
  PRIMARY KEY ((sensor_id, day_bucket), reading_time)
) WITH CLUSTERING ORDER BY (reading_time DESC);

Worked example 1: one partition against daily buckets (run)

I loaded the same 200,000 readings (one every 10 seconds, 100-character payload, about 23 days) into two tables: readings_unbounded with PRIMARY KEY (sensor_id, reading_time) and the bucketed table above. After nodetool flush and nodetool compact, tablestats reported:

Table: readings_unbounded Number of partitions (estimate): 1 Compacted partition maximum bytes: 25109160 Table: readings_bucketed Number of partitions (estimate): 24 Compacted partition maximum bytes: 1131752

Then I traced reads (CONSISTENCY ONE; PAGING OFF; TRACING ON;). The elapsed time is the last column of the Request complete trace line, in microseconds, from two runs:

SELECT count(*) FROM bp.readings_unbounded WHERE sensor_id='sensor-1001'; Read 200000 live rows and 0 tombstone cells Request complete: 325387 / 251841 us SELECT count(*) FROM bp.readings_unbounded WHERE sensor_id='sensor-1001' AND reading_time >= '2026-10-10' AND reading_time < '2026-10-11'; Read 8640 live rows and 0 tombstone cells Request complete: 18476 / 11857 us SELECT count(*) FROM bp.readings_bucketed WHERE sensor_id='sensor-1001' AND day_bucket='2026-10-10'; Read 8640 live rows and 0 tombstone cells Request complete: 14067 / 12379 us

What this shows, honestly: a bounded clustering range inside the big partition was about as fast as the bucket, so a bucket does not make a single read faster. It caps the size of each partition (25.1 MB against at most 1.1 MB here, growing about 1.1 MB per day for this one sensor) and stops a plain WHERE sensor_id = ? from turning into a 200,000-row read. Timings are one local node with one replica and vary between runs.

Indexing in Cassandra 5.0: SAI, Secondary Indexes or More Tables

4. Never use ALLOW FILTERING in application queries

  • What to do: Query by partition key, or create a table for the query (practice 1). Without it, Cassandra refuses the query, as it did here (run):
  • Why: Filtering without a key restriction scans partitions, and the CQL documentation says the performance of such a query can be unpredictable because it grows with the data.
  • How to check: Search the code for ALLOW FILTERING. The allow_filtering_enabled guardrail in cassandra.yaml can switch it off (not run).
cqlsh> SELECT * FROM bp.orders_by_customer WHERE status='SHIPPED'; InvalidRequest: Error from server: code=2200 [Invalid query] message="Cannot execute this query as it might involve data filtering and thus may have unpredictable performance. If you want to execute this query despite the performance unpredictability, use ALLOW FILTERING"

5. Use Storage-Attached Indexes for secondary lookups, not legacy indexes

  • What to do: For a secondary filter, create an SAI index and keep a partition key restriction when you can. Wait for the index build to finish before querying: my first query straight after CREATE INDEX failed with INDEX_NOT_AVAILABLE and worked a few seconds later (run).
  • Why: A legacy secondary index is a per-node structure, so the documentation notes that its results depend on the number of nodes. SAI is the index introduced in 5.0. Without a partition key, an index query can still involve many nodes, so it does not replace practice 1.
  • How to check: Test on production-size data with TRACING ON; small test sets hide fan-out cost.
CREATE INDEX IF NOT EXISTS orders_status_sai
  ON bp.orders_by_customer (status) USING 'sai';

SELECT order_id, status, total FROM bp.orders_by_customer
WHERE customer_id = 7b1f3c52-8a6e-4c1d-9d0e-3f2a5b6c7d88 AND status = 'SHIPPED';

6. Keep IN lists and batches small

  • What to do: Run several prepared single-partition queries in parallel instead of one huge IN on the partition key. Use a logged batch only to keep a few denormalized tables in step, and an UNLOGGED batch only for rows of one partition.
  • Why: An IN on the partition key makes the coordinator fetch each partition and wait for all of them. The documentation says a logged batch across partitions has a performance penalty for atomicity, and an unlogged batch that fails can be partly applied. Batches are not a speed tool.
  • How to check: Watch system.log for batch warnings. The cassandra.yaml reference lists batch_size_warn_threshold (5KiB), batch_size_fail_threshold (50KiB) and unlogged_batch_across_partitions_warn_threshold (10). I did not trigger these warnings.

Consistency Levels and Replication Factor: Choosing LOCAL_QUORUM

7. Use RF=3 per datacenter, LOCAL_QUORUM and NetworkTopologyStrategy

  • What to do: Create keyspaces with NetworkTopologyStrategy, give each datacenter an explicit RF of 3 using the datacenter names your snitch reports, and use LOCAL_QUORUM as the default (CONSISTENCY LOCAL_QUORUM; in cqlsh, or the driver default in practice 12). The documentation says all production deployments should use NetworkTopologyStrategy. After raising an RF, run a full repair (practice 14), and raise system_auth replication to 3 to 5 per datacenter (practice 13). Run on a one-node cluster whose datacenter is datacenter1:
  • Why: A quorum is a majority, n/2 + 1 replicas, which is 2 of 3. Writes of 2 plus reads of 2 is 4, more than RF=3, so every read overlaps a replica that has the latest write. With two datacenters at RF=3 there are 6 replicas, so plain QUORUM needs 4 and must cross the WAN, while LOCAL_QUORUM needs 2 of 3 locally and keeps working if the other datacenter is down. ALL fails when any one replica is down. SimpleStrategy ignores topology.
  • How to check: DESCRIBE KEYSPACE for the replication map and nodetool status for node state (datacenter names must match). Consistency behavior was not run on a multi-node cluster.
CREATE KEYSPACE retail
  WITH replication = {'class': 'NetworkTopologyStrategy', 'datacenter1': 3};
-- Warnings: Your replication factor 3 for keyspace retail is higher than the number
-- of nodes 1 for datacenter datacenter1
LevelReplicas needed (2 DCs, RF=3 each)Use it for
LOCAL_ONE / ONE1Data where a stale read is acceptable
LOCAL_QUORUM2 of 3 in the local DCDefault for multi-DC production
QUORUM4 of 6, crosses DCsSingle-DC clusters
EACH_QUORUM2 of 3 in every DCRare writes that must reach every DC
ALL6 of 6Almost never

Transactions, Counters and Collections: Lightweight Transactions and Their Limits

8. Use lightweight transactions rarely and set Paxos v2

  • What to do: Use IF conditions only where two writers must not both succeed, such as a unique email, and check the [applied] column in code. The cassandra.yaml reference marks paxos_variant: v2 as recommended and safe with paxos_state_purging: repaired; roll it out node by node (not run, needs a rolling restart). Run:
  • Why: Paxos needs several round trips between replicas.
  • How to check: Compare client-side latency for LWT and plain writes, and check [applied] is handled.
CREATE TABLE bp.users_by_email (email text PRIMARY KEY, user_id uuid, created_at timestamp);
INSERT INTO bp.users_by_email (email, user_id, created_at)
  VALUES ('asha@example.com', uuid(), toTimestamp(now())) IF NOT EXISTS;
[applied] ———– True (second identical INSERT) [applied] | email | created_at | user_id ———–+——————+———————————+——— False | asha@example.com | 2026-11-23 18:46:04.487000+0000 | 71f24524-…

9. Treat counters as approximate and keep collections small

  • What to do: Keep counters in a table that holds only counters, give them no TTL, and do not use them where an exact value matters (money, stock). Use set, list or map for a handful of values such as phone numbers, and clustering rows for data that grows. Run:
  • Why: The types documentation lists the limits: counters cannot be in the primary key, a counter table can hold only counters, and counters do not expire. It warns that replaying an update after a timeout may or may not over-count. Collections are meant for relatively small amounts of data, are not indexed internally, and reading one element reads the whole collection.
  • How to check: Reconcile counters against an event table now and then, and do not auto-retry counter updates blindly. For collections, check nodetool tablehistograms cell counts and trace the read.
CREATE TABLE bp.page_hits (page text PRIMARY KEY, hits counter);
UPDATE bp.page_hits SET hits = hits + 1 WHERE page = 'home';

CREATE TABLE bp.profiles (user_id uuid PRIMARY KEY, phones set<text>);
UPDATE bp.profiles SET phones = phones + {'+1-555-0100'}
  WHERE user_id = 7b1f3c52-8a6e-4c1d-9d0e-3f2a5b6c7d88;

Tombstones, TTL and gc_grace_seconds: Deleting Data Safely

10. Prefer TTL and time buckets over deletes, and never write nulls

  • What to do: Let data expire with default_time_to_live or USING TTL, keep time series on TWCS, and leave unknown columns out of the INSERT (or use the driver’s unset value) instead of writing null. Avoid queue tables (insert, read, delete in one partition) and do not lower gc_grace_seconds unless repair runs more often. Run:
  • Why: A delete writes a tombstone that is kept for gc_grace_seconds (default 864000, 10 days) and removed only by compaction, so reads must step over it. A tombstone is also how a replica learns about a delete, which is why repair must finish inside that window (practice 14). The yaml reference sets tombstone_warn_threshold to 1000 and tombstone_failure_threshold to 100000 per read.
  • How to check: system.log warnings, nodetool tablestats (Average/Maximum tombstones per slice) and TRACING ON (Read N live rows and M tombstone cells).
CREATE TABLE bp.cart_events (
  user_id uuid, day_bucket date, event_time timestamp, event_type text,
  PRIMARY KEY ((user_id, day_bucket), event_time)
) WITH CLUSTERING ORDER BY (event_time DESC)
  AND default_time_to_live = 604800
  AND compaction = {'class': 'TimeWindowCompactionStrategy',
                    'compaction_window_unit': 'DAYS', 'compaction_window_size': 1};

INSERT INTO bp.cart_events (user_id, day_bucket, event_time, event_type)
VALUES (uuid(), '2026-11-23', toTimestamp(now()), 'add_to_cart') USING TTL 86400;

Worked example 2: a queue table and a tombstone warning (run)

I inserted 3,000 jobs into one partition of jobs_queue (PRIMARY KEY (queue, job_id)), deleted 2,999 of them one by one, then read one row. The same pattern with an hourly bucket (jobs_bucketed, PRIMARY KEY ((queue, hour_bucket), job_id)) kept the live job in a new bucket. The trace and log showed:

— queue table (one partition) Read 1 live rows and 2999 tombstone cells (see tombstone_warn_threshold) WARN [ReadStage-3] ReadCommand.java:644 – Read 1 live rows and 2999 tombstone cells for query SELECT body FROM bp.jobs_queue WHERE queue = 'emails' LIMIT 1 ALLOW FILTERING; token 5755870324934700989 (see tombstone_warn_threshold) Request complete: 6493 us nodetool tablestats: Average tombstones per slice (last five minutes): 3311.0 — bucketed table, read of the current bucket Read 1 live rows and 0 tombstone cells Request complete: 899 us

The warning appeared at the 1000 default threshold. The bucketed read avoided it because consumed jobs sit in an old bucket that is no longer read. Explicit nulls do the same on a small scale: a row inserted with two null columns traced as 2 tombstone cells, and the same row with those columns left out traced as 0 (run).

Choosing a Compaction Strategy: STCS, LCS, TWCS or UCS

11. Choose the compaction strategy per table, and keep spare disk

  • What to do: The compaction overview recommends UCS for most workloads and for new tables, and STCS is still the default when nothing is set. TWCS is recommended for time-series and TTL data, and LCS for read-heavy workloads where UCS is not used. To move an STCS table to UCS with equivalent behavior, use T4 (the docs give L10 for LCS). Change one table at a time, staging first:
  • Why: Compaction merges SSTables to drop overwritten data and expired tombstones. TWCS groups data into time windows and drops a whole SSTable when everything in it has expired, which only works if data is not written out of order. STCS needs free disk while it merges large SSTables.
  • How to check: nodetool compactionstats (a pending count that keeps growing means compaction cannot keep up) and SSTable count in nodetool tablestats. I ran the ALTER below on a tiny table, which proves the syntax, not the tuning.
ALTER TABLE bp.orders_by_customer
WITH compaction = {'class': 'UnifiedCompactionStrategy', 'scaling_parameters': 'T4'};

Drivers, Connection Management and Security

12. Create one session, prepare statements, be token-aware, and retry only idempotent statements

  • What to do: Build the cluster and session once at startup, prepare repeated queries, name the local datacenter and set the default consistency to LOCAL_QUORUM. Mark statements idempotent only when running them twice is safe, and only then allow retries or speculative execution. C# with CassandraCSharpDriver 3.22.0 on .NET 10 (run, no TLS or credentials; in 3.22 the local datacenter is set through Policies.NewDefaultLoadBalancingPolicy, and a builder method named WithLocalDatacenter does not exist in that version):
  • Why: A prepared statement is parsed once and lets the driver work out which replicas own the partition, so token-aware routing skips an extra hop. A session per request wastes connections, and retrying a non-idempotent write can duplicate it.
  • How to check: Connection and request metrics from the driver, and nodetool clientstats or nodetool tpstats on the node for connection counts and queued requests (not run).
using Cassandra;

var cluster = Cluster.Builder()
    .AddContactPoints("127.0.0.1")
    .WithLoadBalancingPolicy(Policies.NewDefaultLoadBalancingPolicy("datacenter1"))
    .WithQueryOptions(new QueryOptions().SetConsistencyLevel(ConsistencyLevel.LocalQuorum))
    .Build();
var session = await cluster.ConnectAsync("bp"); // build once, share as a singleton
var prepared = await session.PrepareAsync(
    "SELECT order_id, status FROM orders_by_customer WHERE customer_id = ?");
var bound = prepared.Bind(customerId).SetIdempotence(true);
RowSet rows = await session.ExecuteAsync(bound);

13. Turn on authentication, authorization and TLS

  • What to do: In cassandra.yaml set authenticator: PasswordAuthenticator and authorizer: CassandraAuthorizer (the reference lists both and says the defaults allow everyone), enable server_encryption_options and client_encryption_options, create your own superuser, disable the default cassandra role and give each application a minimal role. Set system_auth replication to 3 to 5 per datacenter, as the security documentation advises, so login still works when a node is down. Not run, because it needs a restart with authentication enabled.
  • Why: Authentication proves who is connecting, authorization limits what they can do, and TLS protects traffic between clients and nodes and between nodes.
  • How to check: LIST ROLES;, LIST ALL PERMISSIONS OF app_user; after login, and a failed connection test without credentials.
authenticator: PasswordAuthenticator
authorizer: CassandraAuthorizer
role_manager: CassandraRoleManager

Repair, Backup and Restore Best Practices

14. Repair every node inside gc_grace_seconds, in small regular pieces

  • What to do: The repair documentation says incremental repair is the default and suggests, as a starting point, an incremental repair every 1 to 3 days and a full repair every 1 to 3 weeks (or a full repair every 5 days if you avoid incremental). At a minimum, repair must run often enough that the grace period never expires on unrepaired data. Use -pr on each node, and run a full repair after raising a keyspace RF or adding a node. Auto Repair was backported to 5.0.8 and needs -Dcassandra.autorepair.enable=true before the node starts; external schedulers such as Cassandra Reaper are separate projects (not tested here).
  • Why: Repair compares replicas with Merkle trees and streams the differences. If a replica missed a delete and the others purge the tombstone after gc_grace_seconds, the old row can return as zombie data.
  • How to check: Percent repaired in nodetool tablestats (0.0 on my never-repaired test table), nodetool netstats during a run, and a written schedule that finishes in under 10 days at the default. On a one-replica keyspace nodetool repair -pr bp only reported that no repair is needed, so repair itself was not exercised.
nodetool repair -pr shop_ks     # primary ranges of this node, then move to the next node

15. Take snapshots, copy them off the node, and test restores

  • What to do: Schedule nodetool snapshot with retention and copy the files off the node. Restore a copy into a separate cluster on a schedule, time it, and write the time down. The backups documentation describes snapshots as hard links to SSTables and names sstableloader and nodetool refresh as the restore tools. The snapshot command ran here; a full restore was not run.
  • Why: A snapshot is cheap, consistent per node and quick, but it lives on the same disk until you move it. Only a restore test proves the files, the schema and your procedure work.
  • How to check: List the snapshot directory, compare row counts after a test restore, and note the restore time.
nodetool snapshot -t daily_2026-11-23 shop_ks
# restore test on a separate cluster: schema first, then
sstableloader -d 10.0.1.11,10.0.1.12 /restore/shop_ks/orders_by_customer
nodetool repair shop_ks

Operations, Monitoring and Upgrades

16. Size disks and heap deliberately, and monitor the right signals

  • What to do: Use a supported Java (11 or 17 on 5.0) and start from the JVM options files shipped with your version. The hardware guide says the heap should be at least 2 GB and no more than 50% of RAM, that with spinning disks the commit log (commitlog_directory) should be on a different physical disk from data_file_directories, and that NFS or SAN for data is an anti-pattern. Keep free disk for compaction, disable swap, and run NTP or chrony because conflicting writes are resolved by timestamp. Alert on the signals below:
  • Why: The commit log is written on every write while data files are read by queries, so separate devices stop them competing, and spare disk lets large compactions finish. The signals below are the earliest symptoms of the problems in this guide.
  • How to check: df -h on data and commit log paths, GC lines in system.log (the yaml gc_log_threshold logs pauses over 200 ms by default), and the commands in the table. I ran tpstats, tablestats and tablehistograms on the local node.
SignalWhere to see itWhat it points to
Large partitionsnodetool tablehistograms, tablestatsUnbounded key (practices 2, 3)
Pending compactionsnodetool compactionstatsStrategy or disk throughput (practice 11)
Dropped messages, blocked poolsnodetool tpstatsOverloaded node or slow disk
Tombstone warningssystem.log, tablestatsDeletes and nulls (practice 10)
Slow queriesTRACING ON, driver latency metricsWide reads, filtering, GC
Unrepaired dataPercent repaired in tablestatsRepair schedule (practice 14)

17. Upgrade with rolling restarts and plan node changes

  • What to do: Read NEWS.txt for the target version first, snapshot, repair and check health, freeze schema changes, then upgrade one node at a time: nodetool drain, stop, install, start, and wait for UN in nodetool status. Run nodetool upgradesstables only if the notes require it, and move one major version at a time. When you add nodes, bootstrap them and run nodetool cleanup on the old nodes afterwards. The exact procedure was not run here.
  • Why: Replication means the cluster serves traffic while one node restarts, provided your consistency level tolerates one node down (practice 7) and repair is up to date.
  • How to check: nodetool status and nodetool version on every node, and a rehearsal in staging.
nodetool snapshot -t pre_upgrade shop_ks
nodetool drain
sudo systemctl stop cassandra
# install the new Cassandra version here
sudo systemctl start cassandra
nodetool status        # wait for UN before the next node

Key takeaways

Use this as a production checklist. The anti-patterns behind most incidents are the opposites: queue tables with deletes, null writes, ALLOW FILTERING, large cross-partition batches, ALL by default, skipped repair and untested restores.

  • Every query reads one partition and none uses ALLOW FILTERING; tablehistograms shows maximum partition size well under 100 MB, and time series use buckets.
  • Keyspaces use NetworkTopologyStrategy with RF=3 per datacenter; drivers default to LOCAL_QUORUM with the local datacenter set.
  • Data expires with TTL instead of deletes, every table has a deliberate compaction strategy, and tombstone warnings are monitored.
  • A repair schedule covers all nodes inside gc_grace_seconds; snapshots are copied off the node and a restore has been timed.
  • Authentication, authorization and TLS are on, the default superuser is replaced and system_auth is replicated.
  • A rolling-upgrade runbook has been rehearsed in staging, with alerts for pending compactions, dropped messages and disk use.

The same query-first thinking appears in the guides for Cosmos DB partitioning, Neo4j graph modeling, Redis caching and MongoDB schema design.

What was not run: anything needing several nodes (consistency behavior, repair, rolling upgrades), TLS and authentication, restore from a snapshot, and the guardrail warnings for batches and partition size. All timings come from one local node and are illustrations, not benchmarks.

Found this useful?

Bookmark this page and share it with your team. Get new .NET, cloud and database tutorials in your inbox.

FAQ

What are the most important Cassandra best practices?

Model one table per query, choose a high-cardinality partition key and keep partitions under about 100 MB and 100,000 values. Use LOCAL_QUORUM with RF=3 per datacenter, expire data with TTL instead of deleting, repair inside gc_grace_seconds and test your restores.

What is the ideal partition size in Cassandra?

The official data modeling guide suggests below about 100,000 values and below 100 MB per partition, with a hard limit of 2 billion cells. Check real sizes with nodetool tablehistograms and the compacted partition maximum bytes in nodetool tablestats, and add a time bucket to the partition key if a partition keeps growing.

Which Cassandra consistency level should I use?

For multi-datacenter production use LOCAL_QUORUM for reads and writes with RF=3 per datacenter. A quorum is n/2 + 1 replicas, so 2 reads plus 2 writes exceed RF=3 and every read overlaps the latest write, without waiting on another datacenter.

Sources and further reading

One thought on “Cassandra Best Practices: 17 Rules for Data and Ops”

Leave a Reply

Your email address will not be published. Required fields are marked *