Database / Apache Cassandra Intermediate and Advanced interview questions
When would you choose Leveled Compaction Strategy over Size-Tiered Compaction Strategy?
The choice comes down to whether your workload is more sensitive to read latency or to compaction overhead.
- Choose LCS when reads dominate and you need predictable, low-latency lookups — LCS guarantees a row exists in at most one SSTable per level (aside from level 0), so a read touches far fewer files than under STCS once data has spread across many SSTables.
- Choose LCS for tables with frequent updates to the same rows, since STCS can leave many overlapping versions of a row scattered across differently-sized SSTables, hurting read amplification.
- Avoid LCS on very write-heavy, high-throughput tables, because LCS does significantly more disk I/O for compaction (constantly rewriting to maintain level ordering), which can bottleneck nodes with limited disk throughput.
ALTER TABLE user_profiles WITH compaction = {'class': 'LeveledCompactionStrategy', 'sstable_size_in_mb': 160};
A practical signal: if nodetool cfstats shows a high "SSTables per read count" under STCS, that is a strong indicator the table would benefit from switching to LCS.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
