Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat]: Support Unified Compaction Strategy (UCS) in Cassandra 5.0+ #719

Open
millerjp opened this issue Feb 6, 2025 · 0 comments
Open
Assignees
Labels
enhancement New feature or request right click
Milestone

Comments

@millerjp
Copy link
Contributor

millerjp commented Feb 6, 2025

Cassandra 5.0 introduced UCS. We need to support displaying this in the tree and any syntax validation that checks for compaction settings when creating a table. We also need to update the create table wizards to support UCS as an option when connected to Cassandra 5.0+. Its important that this is only available in this version as its not possible to create tables using UCS prior to 5.0.

https://cassandra.apache.org/doc/latest/cassandra/managing/operating/compaction/ucs.html

Unified Compaction Strategy (UCS) in Apache Cassandra 5.0 is a compaction strategy designed to address the limitations of previous strategies like Size-Tiered Compaction Strategy (STCS) and Leveled Compaction Strategy (LCS).

UCS combines the benefits of both tiered and leveled compaction while introducing sharding capabilities, allowing for concurrent compactions and better management of SSTables.

Pros: UCS is highly adaptable, offering users the flexibility to adjust compaction parameters at any time without requiring full data recompaction. It reduces disk space overhead, improves read and write performance, and can handle a wide range of workloads, from time-series data to general-purpose applications. It also supports sharding, which enables parallel compaction of partitioned data, reducing the size of individual SSTables and improving compaction speed.

Cons: UCS does not mirror the behavior of Time-Window Compaction Strategy (TWCS) for append-only time series data, which might be a limitation for specific use cases. Additionally, while UCS offers better performance, its complexity might require more tuning to achieve optimal results for specific workloads. Overall, UCS provides a unified approach to compaction, simplifying the decision-making process for users and enhancing Cassandra's performance and scalability

To create a table in Apache Cassandra 5.0 using the Unified Compaction Strategy (UCS), you can follow these steps:

  1. Define the Table Structure: First, you need to define the structure of your table, including the columns and the primary key. Here's an example of how to create a table:

    CREATE TABLE IF NOT EXISTS my_keyspace.my_table (
        id UUID PRIMARY KEY,
        name TEXT,
        age INT,
        email TEXT
    ) WITH compaction = {
        'class': 'UnifiedCompactionStrategy',
        'scaling_parameters': 'T8, T4, N, L4'
    };

    In this example:

    • my_keyspace is the keyspace where the table will be created.
    • my_table is the name of the table.
    • id is defined as the primary key, which is also the partition key in this case.
    • The WITH clause specifies the compaction strategy as UCS with specific scaling parameters[3][5].
  2. Compaction Strategy Configuration: The scaling_parameters option in the WITH clause specifies the fan factor and compaction method for each level of the hierarchy. You can customize these parameters to suit your specific workload requirements. If the list is shorter than the number of levels, the last value is repeated for all higher levels[5].

  3. Additional Considerations:

    • Ensure that your Cassandra cluster is configured to support UCS. This might involve setting parameters in the cassandra.yaml file, like concurrent_compactors to manage the number of compaction threads[6].
    • UCS is highly versatile and can be used with any size workload, improving upon previous compaction strategies like STCS and LCS[6].

By following these steps, you can create a table in Cassandra 5.0 with UCS, optimizing your data storage and retrieval for better performance and scalability[3][5][6].

Citations:
[1] https://www.tutorialspoint.com/cassandra/cassandra_create_table.htm
[2] https://www.techbrothersit.com/2018/06/how-to-create-table-in-cassandra.html
[3] https://cassandra.apache.org/doc/latest/cassandra/reference/cql-commands/create-table.html
[4] https://docs.genesys.com/Documentation/GMS/latest/Deployment/ConfiguringanExternalCassandra
[5] https://cassandra.apache.org/_/blog/Apache-Cassandra-5.0-Features-Unified-Compaction-Strategy.html
[6] https://docs.datastax.com/en/planning/oss/schema-tuning.html
[7] https://theravitshow.com/cassandra-5-0-what-do-the-developers-who-built-it-think/
[8] https://docs.datastax.com/en/cql/hcd/reference/cql-commands/create-table.html

@millerjp millerjp added enhancement New feature or request right click labels Feb 6, 2025
@millerjp millerjp added this to the RightClick milestone Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request right click
Projects
None yet
Development

No branches or pull requests

2 participants