How does compression work in Cassandra, and what are the trade-offs of enabling it on tables?
Last updated
SSTables are compressed on disk in independent chunks (
chunk_length_in_kb, default 16KB), and an offset map lets reads decompress only the needed chunk.Enabled by default with
LZ4Compressor(fast, decent ratio). It saves disk and I/O, often boosting read throughput. HeavierZstdCompressor/DeflateCompressorcompress better but cost more CPU.Tradeoffs: larger chunks compress better but slow point reads, smaller chunks favor random reads. Disable it for already-compressed or tiny values.
- https://cassandra.apache.org/doc/latest/cassandra/getting-started/production.html
- https://aws.amazon.com/blogs/database/best-practices-for-running-apache-cassandra-with-amazon-ebs/
- https://cassandra.apache.org/doc/stable/cassandra/managing/operating/compression.html
- https://cassandra.apache.org/doc/4.0/cassandra/operating/compression.html
- https://docs.datastax.com/en/dse/6.9/managing/operations/configure-compression.html
- https://cassandra.apache.org/doc/latest/cassandra/reference/cql-commands/create-table.html
- https://goodspace.ai/interview-questions/cassandra
- https://aws.amazon.com/blogs/database/category/learning-levels/advanced-300/page/33/