Cassandra Architecture Interview Questions
Master Apache Cassandra architecture with interview questions covering Cluster, Node, Ring Architecture, Gossip Protocol, VNodes, Commit Log, Memtable, SSTable, Read/Write Path, Compaction, Repair, and enterprise production concepts.
Introduction
Apache Cassandra is one of the most advanced distributed databases ever built. Unlike traditional relational databases that depend on a master server, Cassandra follows a masterless peer-to-peer architecture, allowing every node to participate equally.
Its architecture enables
- Linear Scalability
- High Availability
- Fault Tolerance
- Multi-Data Center Replication
- Zero Single Point of Failure
Understanding Cassandra architecture is essential for senior backend engineers, database engineers, solution architects, and distributed systems interviews.
Cassandra Cluster Architecture
flowchart LR
Client --> CoordinatorNode
CoordinatorNode --> Node1
CoordinatorNode --> Node2
CoordinatorNode --> Node3
Node1
<-->Node2
Node2
<-->Node3
Node3
<-->Node1
1. What is Cassandra Architecture?
Answer
Cassandra follows a
- Distributed Architecture
- Peer-to-Peer Architecture
- Masterless Architecture
Every node performs
- Reads
- Writes
- Replication
- Communication
There is no master database server.
2. What is a Cassandra Cluster?
A Cluster is a collection of Cassandra nodes working together.
Example
Cluster
├── Node1
├── Node2
├── Node3
└── Node4
The cluster behaves like one logical database.
3. What is a Node?
A Node is a single Cassandra server.
Responsibilities
- Store Data
- Process Reads
- Process Writes
- Replicate Data
- Participate in Gossip
4. What is a Data Center?
A Data Center is a logical group of nodes.
Example
US-East
US-West
Europe
Asia
Each data center can have its own replication factor.
5. What is a Rack?
A Rack is a group of nodes inside a data center.
Example
Data Center
├── Rack 1
│ ├── Node1
│ └── Node2
├── Rack 2
│ ├── Node3
│ └── Node4
Rack awareness improves fault tolerance.
6. Why does Cassandra use Peer-to-Peer Architecture?
Benefits
- No Single Point of Failure
- High Availability
- Easy Horizontal Scaling
- Automatic Failover
7. What is a Coordinator Node?
The Coordinator Node receives client requests.
Responsibilities
- Route Read Requests
- Route Write Requests
- Collect Responses
- Return Final Result
Any node can become a coordinator.
Coordinator Flow
flowchart LR
Client --> Coordinator --> Replica1
Coordinator --> Replica2
Coordinator --> Replica3
8. What is the Cassandra Ring?
All nodes logically form a ring.
Node1
↓
Node2
↓
Node3
↓
Node4
↓
Node1
The ring determines data distribution.
9. What is Token?
Each node owns one or more token ranges.
Example
0
100
200
300
Partition Keys are hashed into tokens.
10. What is a Partitioner?
Partitioner converts
Partition Key
↓
Token
Common Partitioner
- Murmur3Partitioner
Token Distribution
flowchart LR
PartitionKey --> HashFunction --> Token --> ResponsibleNode
11. What are Virtual Nodes (vnodes)?
Instead of one token,
Each node owns multiple token ranges.
Benefits
- Better Load Balancing
- Faster Node Recovery
- Easier Cluster Expansion
VNode Example
Node1
Token 10
Token 200
Token 800
Node2
Token 50
Token 300
Token 900
12. What is Gossip Protocol?
Gossip is Cassandra's internal communication protocol.
Purpose
- Node Discovery
- Health Monitoring
- Cluster Membership
- Failure Detection
Runs every second.
Gossip Architecture
flowchart LR
Node1
<-->Node2
Node2
<-->Node3
Node3
<-->Node4
Node4
<-->Node1
13. What are Seed Nodes?
Seed Nodes help new nodes discover the cluster.
Important
Seed nodes are
NOT
Master nodes.
14. What is Snitch?
Snitch provides topology information.
It understands
- Rack
- Data Center
Popular Snitches
- GossipingPropertyFileSnitch
- SimpleSnitch
15. What is Commit Log?
Every write is first stored in Commit Log.
Purpose
Crash Recovery
Write Path
flowchart LR
Client --> CommitLog --> Memtable --> SSTable
16. What is Memtable?
Memtable is an in-memory write buffer.
Once full
↓
Flushed to SSTable
17. What is SSTable?
SSTable
Sorted String Table
Immutable disk storage file.
Benefits
- Fast Reads
- Sequential Writes
- No In-place Updates
Storage Architecture
flowchart LR
CommitLog --> Memtable --> SSTable
18. What is Bloom Filter?
Bloom Filter quickly determines
Whether data
may exist
inside an SSTable.
Benefits
- Reduce Disk Reads
- Faster Queries
19. What is Partition Index?
Helps Cassandra locate partition data quickly.
20. What is Index Summary?
Stores sampled partition indexes in memory.
Reduces memory usage.
21. What is Compression?
Compresses SSTables on disk.
Benefits
- Save Storage
- Faster Disk Reads
22. Explain Cassandra Write Path.
flowchart LR
Client --> Coordinator --> CommitLog --> Memtable --> SSTable
Steps
- Coordinator receives request.
- Commit Log stores data.
- Memtable stores data in memory.
- Data flushes to SSTable.
23. Explain Cassandra Read Path.
flowchart LR
Client --> Coordinator --> BloomFilter --> Memtable --> SSTables --> Result
Steps
- Check Memtable
- Check Bloom Filter
- Read SSTables
- Merge Results
24. Why are SSTables Immutable?
Benefits
- No Locks
- Fast Writes
- Sequential IO
- Better Performance
25. What is Compaction?
Compaction merges multiple SSTables.
Benefits
- Remove Tombstones
- Merge Updates
- Improve Read Performance
Compaction Flow
flowchart LR
SSTable1 --> Compaction
SSTable2 --> Compaction
SSTable3 --> Compaction
Compaction --> NewSSTable
26. Types of Compaction
- SizeTieredCompactionStrategy (STCS)
- LeveledCompactionStrategy (LCS)
- TimeWindowCompactionStrategy (TWCS)
27. What is Read Repair?
If replicas contain inconsistent data
↓
Coordinator repairs them during reads.
28. What is Hint Handoff?
If one replica is unavailable,
Coordinator stores
Hint
Later delivers data.
Hint Handoff Flow
flowchart LR
Write --> ReplicaDown --> HintStored --> ReplicaOnline --> ReplayHint
29. What is Anti-Entropy Repair?
Synchronizes replicas.
Uses
Merkle Trees
Command
nodetool repair
30. What are Merkle Trees?
Tree structure used to compare replica data efficiently.
Only differences are synchronized.
31. What is Failure Detection?
Uses Gossip protocol.
Nodes exchange heartbeat information.
Unresponsive nodes become
DOWN.
32. What happens when a node fails?
- Coordinator reroutes requests.
- Replicas continue serving data.
- Hint Handoff stores missed writes.
- Repair synchronizes data later.
33. What is Bootstrap?
Adding a new node to the cluster.
The node automatically receives token ranges.
34. What is Decommission?
Gracefully removes a node.
Data is redistributed.
35. What is Rebuild?
Copies data from another data center.
Useful for
Multi-DC deployments.
Enterprise Architecture
flowchart LR
Application --> Coordinator --> Cluster
Cluster --> CommitLog
Cluster --> Memtable
Cluster --> SSTables
Cluster --> Repair
Cluster --> Replication
Enterprise Best Practices
- Use multiple racks.
- Use NetworkTopologyStrategy.
- Keep seed nodes stable.
- Monitor Gossip health.
- Use virtual nodes.
- Schedule regular repairs.
- Choose proper compaction strategy.
- Monitor disk usage.
- Monitor SSTable count.
- Avoid oversized partitions.
Quick Revision
| Component | Purpose |
|---|---|
| Cluster | Collection of Nodes |
| Node | Database Server |
| Coordinator | Handles Client Requests |
| Ring | Logical Data Distribution |
| Token | Data Ownership |
| Partitioner | Generates Tokens |
| Gossip | Node Communication |
| Seed Node | Cluster Discovery |
| Snitch | Topology Awareness |
| Commit Log | Crash Recovery |
| Memtable | In-Memory Buffer |
| SSTable | Immutable Disk Storage |
| Bloom Filter | Avoid Disk Reads |
| Compaction | Merge SSTables |
| Hint Handoff | Store Missed Writes |
| Read Repair | Fix Replica Differences |
| Repair | Synchronize Data |
Interview Tips
Interviewers commonly ask
- Explain Cassandra Write Path.
- Explain Cassandra Read Path.
- What happens when a node fails?
- Why is Cassandra masterless?
- Explain Gossip Protocol.
- Explain Commit Log.
- Why are SSTables immutable?
- Explain Compaction strategies.
- Explain Hint Handoff.
- Explain Read Repair vs Repair.
- Explain Virtual Nodes.
- Why are Seed Nodes required?
Drawing the write path and read path diagrams during interviews often demonstrates a strong understanding of Cassandra internals.
Summary
Apache Cassandra's architecture is built around a peer-to-peer, masterless distributed design that provides high availability, fault tolerance, and linear scalability. Components such as Gossip Protocol, Commit Log, Memtables, SSTables, Bloom Filters, Compaction, Read Repair, Hint Handoff, and Virtual Nodes work together to deliver reliable performance for large-scale distributed applications.
Understanding these architectural components is essential before exploring advanced topics such as Data Modeling, Consistency Levels, Replication Strategies, and Performance Tuning in the upcoming chapters.