Next Generation Cassandra Compaction, Going beyond LCS

Joey Lynch

2019-09-10 12:15 #cassandra

Cassandra users with general purpose workloads typically must choose the lesser of two evils between the default “write optimized” Size Tiered Compaction Strategy (STCS) and the “read optimized” Leveled Compaction Strategy (LCS). It is typical these days to hear “use LCS unless it explodes, in which case use STCS…unless that explodes, in which case you are out of luck”. I believe that by taking what we as a community learned from the development and real world deployment of LCS, we can create a next generation compaction strategy which offers all of the benefits of LCS with few of the drawbacks. I will begin this talk with an overview of the existing general purpose options, and explore their deficiencies. In particular, we will explore how STCS naïvely groups SSTables of similar size together regardless of read amplification, expends system resources compacting data that does not benefit from compaction, and creates large files that are difficult to process both by Cassandra and downstream systems. The LCS compaction algorithm was developed to mitigate many of these issues. However, LCS suffers from issues of its own: implementation bugs caused by the complexity of the algorithm, significant write amplification introduced in the L0 to L1 transition, and a lack of efficient full compaction. LCS is a worthwhile compaction strategy, but these flaws prevent it from being applied universally to general purpose workloads. Once we have a firm understanding of the issues facing current implementations, I will present a number of potential incremental improvements to the existing choices. I’ll also synthesize these ideas into a blueprint for a new, general purpose, compaction strategy. A key design consideration is to offer users a single compaction interface with easy to understand tunables that adapt to all use cases historically covered by either STCS or LCS. Once I have laid out the proposal, I will open the topic for feedback from other developers in the room and I hope that at the end we will have built consensus around the key challenges of Cassandra compaction, as well as come to a decision on the best path forward.