#🧱 Building Block: Apache Cassandra
#Overview
Apache Cassandra is a distributed, wide-column NoSQL database designed for high write throughput and linear horizontal scalability with no single point of failure.
#Key Concepts
- Wide-Column Store: Data organized by partition key and clustering columns, not traditional rows/columns.
- Distributed Architecture: Peer-to-peer ring topology — every node is equal, no master/slave.
- Tunable Consistency: Per-query consistency levels (ONE, QUORUM, ALL) let you trade consistency for availability.
- Partition Key: Determines which node stores the data; critical for even distribution and avoiding hotspots.
- Clustering Key: Determines sort order within a partition; enables efficient range queries.
- Compaction: Background process that merges SSTables and removes tombstones (deleted data markers).
#When to Use
- High Write Throughput: Event logging, time-series data, IoT sensor data (100K+ writes/sec).
- Time-Series Access Patterns: Transaction history, user activity feeds (partition by entity, sort by timestamp).
- Multi-Region Replication: Built-in cross-datacenter replication for global applications.
- No Single Point of Failure: Financial systems, fraud detection where downtime is unacceptable.
#When NOT to Use
- Complex joins or ad-hoc queries (use PostgreSQL).
- Strong consistency required on every read (use PostgreSQL or DynamoDB with strong reads).
- Small datasets (< 10GB) — overkill operationally.
#Trade-offs
- Pros: Linear scalability, high write throughput, no master node, tunable consistency, excellent multi-DC replication.
- Cons: No joins or aggregations, data modeling driven by query patterns (denormalization required), tombstone management complexity, operational overhead.
#Used In This Repo
- Recommendation Engine (#23) — Interaction event store (50B events/day)
- Fraud Detection (#24) — Transaction record store (2B transactions/day)