Performance tuning properties
Tuning performance and system resource utilization, including commit log, compaction, memory, disk I/O, CPU, reads, and writes.
Commit log settings
commitlog_sync
(Default: periodic)
The method that Cassandra uses to acknowledge writes in milliseconds:
- periodic: (Default: 10000 milliseconds [10 seconds])
With commitlog_sync_period_in_ms, controls how often the commit log is synchronized to disk. Periodic syncs are acknowledged immediately.
- batch: (Default: disabled)note
Used with commitlog_sync_batch_window_in_ms (Default: 2 ms), which is the maximum length of time that queries may be batched together.
commitlog_segment_size_in_mb
(Default: 32MB)
The size of an individual commitlog file segment. A commitlog segment may be archived, deleted, or recycled after all its data has been flushed to SSTables. This data can potentially include commitlog segments from every table in the system. The default size is usually suitable for most commitlog archiving, but if you want a finer granularity, 8 or 16 MB is reasonable.
By default, the max_mutation_size_in_kb is set to half of the commitlog_segment_size_in_kb.
max_mutation_size_in_kb
(Default: ½ of commitlog_segment_size_in_mb)
If a mutation's size exceeds this value, the mutation is rejected. Before increasing the commitlog segment size of the commitlog segments, investigate why the mutations are larger than expected. Look for underlying issues with access patterns and data model, because increasing the commitlog segment size is a limited fix.
Restriction:
If you set max_mutation_size_in_kb explicitly, then you must set commitlog_segment_size_in_mb to at least twice the size of max_mutation_size_in_kb / 1024.
For more information, see commitlog_segment_size_in_mb above.
commitlog_compression
(Default: not enabled)
The compressor to use if commit log is compressed. Valid values: LZ4, Snappy or Deflate. If no value is set for this property, the commit log is written uncompressed.
cdc_total_space_in_mb
(Default: 4096MB and 1/8th of the total space of the drive where the cdc_raw_directory resides)note
If space gets above this value, Cassandra will throw WriteTimeoutException on Mutations including tables with CDC enabled. A CDCCompactor (a consumer) is responsible for parsing the raw CDC logs and deleting them when parsing is completed.
cdc_free_space_check_interval_ms
(Default: 250 ms)note
When the cdc_raw limit is hit and the CDCCompactor is either running behind or experiencing backpressure, this interval is checked to see if any new space for cdc-tracked tables has been made available.
commitlog_total_space_in_mb
(Default: 32MB for 32-bit JVMs, 8192MB for 64-bit JVMs)note
Total space used for commit logs. If the total space used by all commit logs goes above this value, Cassandra rounds up to the next nearest segment multiple and flushes memtables to disk for the oldest commitlog segments, removing those log segments from the commit log. This reduces the amount of data to replay on start-up, and prevents infrequently-updated tables from keeping commitlog segments indefinitely. If the commitlog_total_space_in_mb is small, the result is more flush activity on less-active tables.
Compaction settings
concurrent_compactors
(Default: Smaller of number of disks or number of cores, with a minimum of 2 and a maximum of 8 per CPU core)note
The number of concurrent compaction processes allowed to run simultaneously on a node, not including validation compactions for anti-entropy repair. Simultaneous compactions help preserve read performance in a mixed read-write workload by limiting the number of small SSTables that accumulate during a single long-running compaction. If your data directories are backed by SSDs, increase this value to the number of cores. If compaction running too slowly or too fast, adjust compaction_throughput_mb_per_sec first.
Note: Increasing concurrent compactors leads to more use of available disk space for compaction, because concurrent compactions happen in parallel, especially for STCS. Ensure that adequate disk space is available before increasing this configuration.
sstable_preemptive_open_interval_in_mb
(Default: 50MB)
The compaction process opens SSTables before they are completely written and uses them in place of the prior SSTables for any range previously written. This setting helps to smoothly transfer reads between the SSTables by reducing page cache churn and keeps hot rows hot.
Memtable settings
memtable_allocation_type
(Default: heap_buffers)
The method Cassandra uses to allocate and manage memtable memory. See Off-heap memtables in Cassandra 2.1. In releases 3.2.0 and 3.2.1, the only option that works is: heap-buffers (On heap NIO (non-blocking I/O) buffers).
memtable_cleanup_threshold
(Default: 1/(memtable_flush_writers + 1))note
Ratio used for automatic memtable flush. Cassandra adds memtable_heap_space_in_mb to memtable_offheap_space_in_mb and multiplies the total by memtable_cleanup_threshold to get a space amount in MB. When the total amount of memory used by all non-flushing memtables exceeds this amount, Cassandra flushes the largest memtable to disk.
A larger value for memtable_cleanup_threshold means larger flushes, less frequent flushes and potentially less compaction activity, but also less concurrent flush activity, which can make it difficult to keep your disks saturated under heavy write load.
file_cache_size_in_mb
(Default: Smaller of 1/4 heap or 512)
Total memory to use for SSTable-reading buffers.
buffer_pool_use_heap_if_exhausted
(Default: true)note
Indicates whether Cassandra allocates allocate on-heap or off-heap memory when the SSTable buffer pool is exhausted (when the buffer pool has exceeded the maximum memory file_cache_size_in_mb), beyond this amount, Cassandra stops caching buffers, but allocates on request.
memtable_flush_writers
(Default: Smaller of number of disks or number of cores with a minimum of 2 and a maximum of 8)note
The number of memtable flush writer threads. These threads are blocked by disk I/O, and each one holds a memtable in memory while blocked. If your data directories are backed by SSDs, increase this setting to the number of cores.
Cache and index settings
column_index_size_in_kb
(Default: 64)
Granularity of the index of rows within a partition. For huge rows, decrease this setting to improve seek time. If you use key cache, be careful not to make this setting too large because key cache will be overwhelmed. If you're unsure of the size of the rows, it's best to use the default setting.
index_summary_capacity_in_mb
(Default: 5% of the heap size [empty])note
Fixed memory pool size in MB for SSTable index summaries. If the memory usage of all index summaries exceeds this limit, any SSTables with low read rates shrink their index summaries to meet this limit. This is a best-effort process. In extreme conditions, Cassandra may use more than this amount of memory.
index_summary_resize_interval_in_minutes
(Default: 60 minutes)
How frequently index summaries should be re-sampled. Re-sampling is done periodically to redistribute memory from the fixed-size pool to SSTables proportional their recent read rates. To disable, set to -1. This setting leaves existing index summaries at their current sampling level.
Disks settings
stream_throughput_outbound_megabits_per_sec
(Default: 200 Mbps)note
Throttle for the throughput of all outbound streaming file transfers on a node. Cassandra does mostly sequential I/O when streaming data during bootstrap or repair. This can saturate the network connection and degrade client (RPC) performance.
inter_dc_stream_throughput_outbound_megabits_per_sec
(Default: unset)note
Throttle for all streaming file transfers between datacenters, and for network stream traffic as configured with stream_throughput_outbound_megabits_per_sec.
trickle_fsync
(Default: false)
When set to true, causes fsync to force the operating system to flush the dirty buffers at the set interval trickle_fsync_interval_in_kb. Enable this parameter to prevent sudden dirty buffer flushing from impacting read latencies. Recommended for use with SSDs, but not with HDDs.
trickle_fsync_interval_in_kb
(Default: 10240). The size of the fsync in kilobytes.