Database / Apache Cassandra Intermediate and Advanced interview questions
What are virtual nodes (vnodes) and why does Cassandra use them?
Before vnodes, each physical node owned exactly one large, contiguous token range on the ring. That made rebalancing painful: adding or removing a node meant recalculating and manually moving huge chunks of token ranges.
Virtual nodes (vnodes) let each physical machine own many small, randomly distributed token ranges (controlled by the num_tokens setting) instead of one big one.
- Even distribution: data and load spread more evenly across the cluster, even with heterogeneous hardware.
- Faster rebuilds: when a node joins or leaves, its many small ranges are sourced from and distributed to many different nodes in parallel, instead of one or two neighbors carrying the whole burden.
- Simpler operations: no need to hand-calculate token assignments when scaling the cluster.
# cassandra.yaml num_tokens: 16 # typical modern default, was 256 in early versions
The trade-off is slightly higher metadata overhead and more replicas potentially involved in any single repair, but for almost all production clusters the operational simplicity and even load distribution are well worth it.
More Related questions...