How does cassandra find the node that contains the data?

前端 未结 3 1474
你的背包
你的背包 2020-12-23 12:16

I\'ve read quite a few articles and a lot of question/answers on SO about Cassandra but I still can\'t figure out how Cassandra decides which node(s) to go to when it\'s rea

3条回答
  •  再見小時候
    2020-12-23 12:32

    Cassandra will locate any data based on a partition key that is mapped to a token value by the partitioner. Tokens are part of a finite token ring value range where each part of the ring is owned by a node in the cluster. The node owning the range of a certain token is said to be the primary for that token. Replicas will be selected by the data replication strategy. Basically this works by going clockwise in the token ring, starting from the primary, and stopping depending on the number of required replicas.

    What's important to realize is that each node in the cluster is able to identify the nodes responsible for a certain key based on the logic described above. Whenever a value is written to the cluster, the node accepting the request (the coordinator node) will know right away the nodes that need to execute the write.

    In case of multiple data-centers, all keys will be mapped across all DCs to the exact same token determined by the partitioner. Cassandra will try to write to each DC and each DC's replicas.

提交回复
热议问题