What are advanced Cassandra data modeling patterns?
Answer
Advanced Cassandra data modeling patterns: 1. Bucket pattern: limit partition size by bucketing: PRIMARY KEY ((user_id, week), event_time). Each week is a separate partition, preventing unbounded growth. 2. Queue / inbox pattern: simulate a queue with Cassandra: PRIMARY KEY (queue_name, created_at). Consumers delete messages after processing (using TTL or explicit delete). Cassandra is not ideal for queues due to tombstones — use sparingly. 3. Token-based pagination: WHERE token(partition_key) > token(?) for efficient cluster-wide pagination without ALLOW FILTERING. 4. Reference data with frozen collections: embed related data as FROZEN<LIST<address>> — stored as a blob, entire collection replaces on update. Good for rarely-changed nested data. 5. Table-per-query: create a dedicated table for each access pattern with the query's filter columns as the partition key. 6. Hybrid Cassandra + search: Cassandra for writes and primary storage, Elasticsearch for complex queries (full-text, multi-field filters). Sync via Kafka/Debezium. This pattern is used by many large-scale applications (Twitter, Netflix) to leverage Cassandra's write scalability with search's query flexibility.
Previous
How do you implement the outbox pattern with RabbitMQ?
Next
What is the difference between RabbitMQ Classic, Quorum, and Stream queue types?
More RabbitMQ & Cassandra Questions
View all →- Advanced What are Cassandra's anti-patterns and how do you avoid them?
- Advanced How does RabbitMQ handle message ordering and exactly-once delivery?
- Advanced What is Cassandra multi-datacenter architecture and geo-distribution?
- Advanced How does RabbitMQ federation and shovel work for multi-datacenter setups?
- Advanced What is Cassandra's SASI index?