0

We use a multi-data center (DC) cassandra cluster. During write on to the cluster, I want only LOCAL DC to perform writes on its nodes as we are already routing the write requests to the desired DC only based on the source from where write is initiated. So, I want only LOCAL DC to process the write and no other DC to perform the writes on its nodes. But later on by virtue of replication among nodes across DCs, I want the written data to be replicated across DCs. Is this replication across DCs possible when I am restricting the write to only one DC in the first place.If I do not open connections to REMOTE hosts lying in different DCs during my write operation, is data replication possible amongst DCs later on. Why I definitely need replicas of data in all DCs is because during data read from cluster, we want the data to be read from any DC the read request falls on, not necessarily the LOCAL one.

Do anyone has solution to this?

Erick Ramirez
  • 13,964
  • 1
  • 18
  • 23
Parul Chourasia
  • 107
  • 1
  • 11
  • Will you perform immidiate read after write ? For how long you are closing connection between dcs ? – Laxmikant Jul 21 '18 at 01:50
  • @Laxmikant: depending upon the situation i'll write, as of now there is no such requirement. And second ques i didn't understand. can you please elaborate. thanks – Parul Chourasia Jul 21 '18 at 18:39
  • when you say you want local dc to perform write, I assume that you will be using write CL as LOCAL_ONE or LOCAL_QUORAM ..am i right ? Now if you use read consistency level also LOCAL then there is chance that while reading you will get stale data if data is not replicated. What read and write consistency level you are planning to have ? what is RF u have per dc ? these two parameters will decide the consistency. – Laxmikant Jul 23 '18 at 04:44
  • @Laxmikant: i'm not sure which consistency level to be applied in my case, I just want my plan to be executed well. do u have any idea which CL will be suited for above mentioned criteria in the description part. – Parul Chourasia Jul 23 '18 at 07:48
  • There is no single answer to this question it depends on use cases however in general Consistency Levels (R+W) greater than Replication Factor (N) will give you consistent result – Laxmikant Jul 23 '18 at 14:14
  • @Laxmikant: does DCawareRR or tokenaware policy hepls here to achieve the above ,mentioned task? – Parul Chourasia Jul 24 '18 at 06:11
  • No that does not assure consistency across dcs. I would recommend to watch below video this might be helpful https://youtu.be/vJVHfqE2mPM – Laxmikant Jul 24 '18 at 12:04
  • if i use write consistency=local_quorum & read consistency= any,then what could be the possible solution? @Laxmikant – Parul Chourasia Jul 25 '18 at 07:06
  • there is no any read CL, minimum read CL is ONE, in multi dc, wcl = local_quorum and read = ONE wont guarantee consistency.. to understand more about CL and RF read cassandra documentation check this as well https://stackoverflow.com/questions/24587869/understand-cassandra-replication-factor-versus-consistency-level . – Laxmikant Jul 25 '18 at 08:10

1 Answers1

0
  1. You may want to use Local_Quorum consistency for writes if you want to perform them in only Local DC.
  2. Check keyspace definition for the one you want these restriction. It should have class "Network topology" and RF in both DC. Something like this: ALTER KEYSPACE <Keyspace_name> WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', 'dc1' : 3, 'dc2' : 2}; It states that after consistency is satisfied Cassandra will propagate the writes to another DC.

  3. Use Quorum consistency for reads if they are not restricted to one DC but be aware that it might add bit latency because Cassandra has to read data from other data center as well.

Payal
  • 564
  • 3
  • 12
  • hi payal ..considering your example : 'dc1' : 3, 'dc2' : 2 ; the write consistency = local-quorum (ie, 2) and read consistency = quorum (ie, 3) in this case wont guarantee that you will always get the latest data. Notice that here R+W =5 is not greater than N =5 hence not a strong consistency.. Take an example : 1. data written in dc2 ...and getting read on dc1 before it could get replicated to dc1 from dc2..you will get stale data.. – Laxmikant Aug 08 '18 at 10:12
  • That was my bad. I dint mean it but while writing i guess i did mistake. Thanks for pointing it out. – Payal Aug 09 '18 at 10:01