ZachB
ZachB

Reputation: 15366

Difference between replicas and virtual nodes in consistent hashing

This is perhaps specific to an implementation that I'm looking at (node-hashring), but what is the difference between virtual nodes (vnodes) and replicas in a consistent hash ring?

The original Akamai paper does not seem to describe vnodes explicitly, and various other sources seem to use the two terms interchangeably (e.g. "virtual nodes", which are replicas of cache points in the circle, from source).

The docs for node-hashring give the example 40 hashes (vnodes) and 4 replicas per hash = 160 points per server. Despite reading the source, I can't quite figure out what these two different parameters do.

Upvotes: 6

Views: 2539

Answers (1)

automata
automata

Reputation: 41

vnodes are different from replicas. vnodes are just the labels given to a physical node in the consistent hash ring in order to maintain more even distribution of data. While replica is a copy of the data stored by the adjacent servers which come into play when that server goes down or is removed from the ring. For eg. if node1 has 40 virtual nodes, then all the data whose hash values fall in the range of the vnodes will be stored and served by node1. Also, node1 can have 4 replicas, which means 4 adjacent servers will be storing copy of the data of node1 and will serve them when node1 goes down.

Upvotes: 1

Related Questions