본문 바로가기

Cassandra

Cassandra - ConsistencyLevel 정리


참조 : http://wiki.apache.org/cassandra/API


ConsistencyLevel 은 일관성을 최대한 보장하기 위한 옵션값인듯 하다


음.. 그러니까 

데이터를 쓸때 n개의 DB 서버 중에

한군데만 쓰기가 완료되도 ok

두군데서만 쓰기가 완료되도 ok

세군데, n/2 + 1 ....


데이터를 불러올때 n개의 DB 서버 중에 

제일빨리 응답한놈데이터를 쓸것이냐, 

서버 2개에서 데이터를 읽어서 가장 최근 자료를 쓸 것이냐

서버 3개, n/2 + 1 ....


뭐 이런 규칙을 정의한듯 (영어가 짧아서...)



Write

Level

Behavior

ANY

Ensure that the write has been written to at least 1 node, including HintedHandoff recipients.

ONE

Ensure that the write has been written to at least 1 replica's commit log and memory table before responding to the client.

TWO

Ensure that the write has been written to at least 2 replica's before responding to the client.

THREE

Ensure that the write has been written to at least 3 replica's before responding to the client.

QUORUM

Ensure that the write has been written to N / 2 + 1 replicas before responding to the client.

LOCAL_QUORUM

Ensure that the write has been written to <ReplicationFactor> / 2 + 1 nodes, within the local datacenter (requires NetworkTopologyStrategy)

EACH_QUORUM

Ensure that the write has been written to <ReplicationFactor> / 2 + 1 nodes in each datacenter (requires NetworkTopologyStrategy)

ALL

Ensure that the write is written to all N replicas before responding to the client. Any unresponsive replicas will fail the operation.



Read

Level

Behavior

ANY

Not supported. You probably want ONE instead.

ONE

Will return the record returned by the first replica to respond. A consistency check is always done in a background thread to fix any consistency issues when ConsistencyLevel.ONE is used. This means subsequent calls will have correct data even if the initial read gets an older value. (This is calledReadRepair)

TWO

Will query 2 replicas and return the record with the most recent timestamp. Again, the remaining replicas will be checked in the background.

THREE

Will query 3 replicas and return the record with the most recent timestamp.

QUORUM

Will query all replicas and return the record with the most recent timestamp once it has at least a majority of replicas (N / 2 + 1) reported. Again, the remaining replicas will be checked in the background.

LOCAL_QUORUM

Returns the record with the most recent timestamp once a majority of replicas within the local datacenter have replied.

EACH_QUORUM

Returns the record with the most recent timestamp once a majority of replicas within each datacenter have replied.

ALL

Will query all replicas and return the record with the most recent timestamp once all replicas have replied. Any unresponsive replicas will fail the operation.




반응형