注册 登录  
 加关注
查看详情
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

zorksylar

Nothing is impossible , if distributed.

 
 
 

日志

 
 

【cassandra】Data Consistency in Cassandra  

2012-07-14 14:32:04|  分类: Distributed |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
       因为每个数据有很多replica,所以这些replica 的consistency就非常重要了,Cassandra提供的是一种tunable consistency,并且是eventual consistency的。tunable consistency的意思是对每个read/write的请求,client会指出这个操作的consisitecy level是多少,比较灵活,可以改变。
       除了tunable consistency之外,Cassandra还有内置的repair机制,用于保持replica的一致性。

      Tunable Consistency for Client Requests
      因为client对每个请求都可以指出特定的consistency,所以,在cassandra中定义了一些consistency level,用户在请求的时候需要指出这样的consistency level。
      Write Consistency
      当client发出一个write请求和write consistency level 发出之后,Cassandra只有当write 指定书目的replica 成功之后,才能够给client返回write 完毕。
     ANY 是最低的consistency level , ALL是最高的consistency level .
     QUORUM中的quorum = RF/2 + 1. ( / 是round down的,如RF=3,quorum=2).

 Level Description
 ANY A write must be written to at least one node. If all replica nodes for the given row key  are down, the write can still succeed once a hinted handoff has been written. Note that  if all replica nodes are down at write time, an ANY write will not be readable until the  replica nodes for that row key have recovered.
 ONE A write must be written to the commit log and memory table of at least one replica  node.(也就是说要wirte到2个Node中,一个为Node,一个为replica Node)
 QUORUM A write must be written to the commit log and memory table on a quorum of replica  nodes.
 LOCAL_QUORUM  A write must be written to the commit log and memory table on a quorum of replica  nodes in the same data center as the coordinator node. Avoids latency of inter-data  center communication.
 EACH_QUORUM A write must be written to the commit log and memory table on a quorum of replica  nodes in all data centers.
 ALL A write must be written to the commit log and memory table on all replica nodes in the  cluster for that row key.
   
      Read Consistency
      同write consistency,只不过是read操作。另外要注意,如果各个replica数据不一样的时候,应该返回哪个?在write 的时候,cassandra会记录write的timestamp,返回的时候会根据timestamp来决定返回哪个replica。
      ONE是最小的consistency level, ALL是最大的consistency level。
      QUORUM中的quorum = RF/2 + 1. ( / 是round down的,如RF=3,quorum=2).
 Level Description
 ONE Returns a response from the closest replica (as determined by the snitch). By default, a read repair runs in the background to make the other replicas consistent.
 QUORUM Returns the record with the most recent timestamp once a quorum of replicas has responded.
 LOCAL_QUORUM Returns the record with the most recent timestamp once a quorum of replicas in the current data center as the coordinator node has reported. Avoids latency of inter-data center communication.
 EACH_QUORUM Returns the record with the most recent timestamp once a quorum of replicas in each data center of the cluster has responded.
 ALL Returns the record with the most recent timestamp once all replicas have responded. The read operation will fail if a replica does not respond.
   
注意:LOCAL_QUORUM 和 EACH_QUORUM 是工作在采用rack-ware replica placement strategy 的用了合适的snitch 的multi-data center cluster 下的。

  评论这张
 
阅读(749)| 评论(2)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018