user1944408
user1944408

Reputation: 569

Consistency strategy for two datacenters

What is the best write/read strategy that is fault tolerant and fast for reads when all nodes are up?

I have 2 replicas in each datacenter and at first I was considering using QUORUM for writes and LOCAL_QUORUM for reads but reads would fail if one node crashes.

The other strategy that I came up with is to use QUORUM for writes and TWO for reads. It should work fast in normal conditions (because we will get results from the nearest nodes first) and it will work slower when any node crashes.

  1. Is this a situation where it is recommended to use consistency level TWO or it is for some other purpose?
  2. When would you use CL THREE?
  3. Do you have a better strategy for consistent and fault tolerant writes/reads?

Upvotes: 2

Views: 1093

Answers (1)

sbridges
sbridges

Reputation: 25150

You first have to chose if you want consistency or availability. If you chose consistency, then you need to have R + W > N, where R is how many nodes you read from, W is how many nodes you write to, and N is the number of replicas.

Then you have to chose if you want reads/writes to always span multiple data centers.

Once you make those choices, you can then chose you consistency level (or it will be dictated to you).

If, for example, you decide you need consistency, and you don't want writes/reads to span multiple data centers, then you can read at LOCAL_QUORUM (which is 2 in your case) and write at ONE, or vice versa.

2 copies per dc is an odd choice. Typically you want to do LOCAL_QUORUM, with 3 replicas in each data center. That lets you read and write only using nodes within a datacenter, but allows 1 node to go down.

Upvotes: 2

Related Questions