Search code examples
erlangriak

A simple explanation of Rings in Riak?


I'm trying to understand what the "rings" in Riak are, but I can't seem to find a clear explanation (please don't just link me to a web site, I have already read what is on the web). As far as I understand a node in Riak is a partition in a ring. Is that correct?


Solution

  • I know you've said you read everything on the web already, but for others also reading this question, I'd like to post two resources that discuss Riak's "ring":

    http://riak.basho.com/arch.html

    http://riak.basho.com/edoc/architecture.txt

    With that out of the way, Riak uses the word "ring" in two places. The first is to describe the hash space that is used for determining where to store data. The reason Riak calls that space a ring is that the last value in the space (2^160-1) is thought of as being adjacent to the first value in the space (0). Replicas of data are stored in the "next N partitions" of the hash space, following the partition to which the key hashes. Considering the hash space as a ring gives a convenient definition for the "next parition after the final partition."

    The other use of the word "ring" is related to, but not exactly the same as the former. I mentioned partitions: each node claims several segments of the hash space, called partitions. Knowledge about which node has claimed which partition is stored in a structure that Riak calls the "ring state", or sometimes just the "ring." Other cluster metadata may also be kept in the ring state, because it's a conveniently shared piece of data throughout the cluster.

    In general usage, an application shouldn't need to think about the ring much.

    Does that answer your question? I'd encourage you to post questions like this to the riak-users mailing list ( http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com ). I'm sure other members of that list are interested in these answers, and we (the Riak developers) tend to be more attentive to that feed than this one.