What is range in cockroachdb

(dung) #1

hey guy, i try 20 nodes by docker in some nodes is replicated in range like picture.
but i don’t know how can is split range?
is it random?
can you explain me?

(Ron Arévalo) #2

Hi @matdieuhau,

CockroachDB stores all user data (tables, indexes, etc.) and almost all system data in a giant sorted map of key-value pairs. This keyspace is divided into “ranges”, contiguous chunks of the keyspace, so that every key can always be found in a single range. CockroachDB replicates each range (3 times by default) and stores each replica on a different node.

The matrix in your screenshot shows you each range(rows), what nodes(columns), have replicas on them(cells).

Ranges are evenly distributed across all your nodes. You may wish to look at our Architecture overview docs here.



(dung) #3

thank you but can you explain me why the node join the range?
it is random?


(Ron Arévalo) #4

Hey @matdieuhau,

I’m not sure I understand your question, are you asking how replicas are distributed to nodes? If so, this usually happens when ever a node joins or leaves a cluster.

There is some more information on load based replica rebalancing here.



(dung) #5

hi @ronarev,
in my picture you can see node 13, node 16 and node 3 in range 1, and the other node in other range.

and i don’t know why cockroach db can choose the node in the range,
why node in range 1 not node 1, node 2, node 3?
the selection of node 1 range is random or it do with rule?