Database Reference
In-Depth Information
num_tokens versus initial_token
The
num_tokens
and
initial_token
define the way you want your cluster to be set
up.
num_tokens
says that the cluster is a modern one with vnodes, and this is the default
setting in Cassandra 1.2 and newer versions. The
initial_token
is the old approach
where each node can handle just one token and is responsible for one range of row keys.
The
initial_token
is commented by default.
It is recommended to use vnodes and
num_tokens
if you are setting up a new Cassandra
cluster. A vnode solves a couple of critical problems; for example one is load balancing,
which is needed no more. With
intial_token
, if you added or removed servers, you
would need to rebalance the cluster by manually setting
initial_token
and moving re-
cords over. This approach is error-prone, complex, and unnecessary. Vnode solves this
problem. With a vnode, the data is assigned and distributed in such a way that cluster load
is balanced between incoming and outgoing nodes. For a vnode, replacing a node or start-
ing up a dead node is a network-centric activity where data from replicas gets copied to the
newly booted server. With vnodes, most of the servers in the ring, if not all, participate in
the streaming of the data to a new server. In a no vnode case, only a small percentage of a
cluster is involved in data streaming. This makes recovery fragile and slow.