Study notes from DS201: Foundations of Apache Cassandra™ and DataStax Enterprise.
VNode (Virtual Node)
In early versions of Cassandra, each physical node was responsible for a single large token range on the ring. This design required massive data redistribution when nodes were added, removed, or experienced failures, resulting in significant operational overhead.
To address this issue, VNodes (virtual nodes) were introduced in Cassandra 1.2. VNodes create multiple virtual nodes per physical node, each responsible for a small token range on the ring.
How VNodes Work and Their Benefits
Ownership of multiple token ranges: With VNodes, a single physical node owns multiple small token ranges on the ring. This allows data to be distributed more finely and evenly across the entire cluster.
Efficient data redistribution:
- Adding nodes: When a new node joins the cluster, it takes over data by “stealing” small token ranges from existing nodes. This speeds up the data redistribution process and minimizes the impact on the cluster.
- Removing nodes / Failures: When a node leaves the cluster or fails, the token ranges it was responsible for are evenly redistributed among the remaining nodes. Thanks to VNodes, the amount of data each node needs to take over is smaller, making the recovery process faster.
Simplified management: VNodes eliminate the need for manual token assignment and complex data redistribution planning when adding or removing nodes. This greatly simplifies cluster management.
Improved performance and availability:
- Even load balancing: Since data is distributed more evenly, load balancing across the entire cluster is improved.
- Faster recovery: Data redistribution during node failures becomes more efficient, improving cluster availability.
VNodes are an important feature that significantly improves the performance, availability, and operational flexibility of Cassandra clusters. Today, VNodes are the default behavior in Cassandra, and it is recommended to keep them enabled unless there is a specific reason not to.