You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Jay Parashar <jp...@itscape.com> on 2012/07/17 19:02:45 UTC
Replication factor - Consistency Questions
Hello all,
There is a lot of material on Replication factor and Consistency level but I
am a little confused by what is happening on my setup. (Cassandra 1.1.2). I
would appreciate any answers.
My Setup: A cluster of 2 nodes evenly balanced. My RF =2, Consistency Level;
Write = ANY and Read = 1
I know that my consistency is Weak but since my RF = 2, I thought data would
be just duplicated in both the nodes but sometimes, querying does not give
me the correct (or gives partial) results. In other times, it gives me the
right results
Is the Read Repair going on after the first query? But as RF = 2, data is
duplicated then why the repair?
Note: My query is done a while after the Writes so data should have been in
both the nodes. Or is this not the case (flushing not happening etc)?
I am thinking of making the Write as 1 and Read as QUORAM so R + W > RF (1 +
2 > 2) to give strong consistency. Will that affect performance a lot
(generally speaking)?
Thanks in advance
Regards
Jay
Re: Batch update efficiency with composite key
Posted by Sylvain Lebresne <sy...@datastax.com>.
On Sat, Jul 21, 2012 at 12:04 AM, Kirk True <ki...@mustardgrain.com> wrote:
> I was aware of the read-then-write pattern for counters, but not secondary
> indexes. I'll have to take a look into that.
Fyi, if you are interested by the subject,
https://issues.apache.org/jira/browse/CASSANDRA-2897 is relevant.
--
Sylvain
>
> Thanks.
>
>
> On 07/20/2012 02:32 AM, aaron morton wrote:
>
> I'm assuming the logical row is in a CQL 3 CF with composite PRIMARYKEY
> http://www.datastax.com/dev/blog/whats-new-in-cql-3-0
>
> It will still be a no look write. The exception being secondary indexes and
> counters which include reads in the write path.
>
> Cheers
>
> -----------------
> Aaron Morton
> Freelance Developer
> @aaronmorton
> http://www.thelastpickle.com
>
> On 20/07/2012, at 10:26 AM, Kirk True wrote:
>
> In Cassandra you don't read-then-write updates, you just write the updates.
>
> Sorry for being dense, but can you clarify a logical vs. physical row?
>
> Batching is useful for reducing round trips to the server.
>
> On 07/18/2012 06:18 AM, Leonid Ilyevsky wrote:
>
> I have a question about efficiency of updates to a CF with composite key.
>
>
>
> Let say I have 100 of logical rows to update, and they all belong to the
> same physical wide row. In my naïve understanding (correct me if I am
> wrong), in order to update a logical row, Cassandra has to retrieve the
> whole physical row, add columns to it, and put it back. So I put all my 100
> updates in a batch and send it over. Would Cassandra be smart enough to
> recognize that they all belong to one physical row, retrieve it once, do all
> the updates and put it back once? Is my batch thing even relevant in this
> case? What happens if I just send updates one by one?
>
>
>
> I want to understand why I should use batches. I don’t really care about one
> timestamp for all records, I only care about efficiency. So I thought, I
> want to at least save on the number of remote calls, but I also wonder what
> happens on Cassandra side.
>
>
>
>
> ________________________________
> This email, along with any attachments, is confidential and may be legally
> privileged or otherwise protected from disclosure. Any unauthorized
> dissemination, copying or use of the contents of this email is strictly
> prohibited and may be in violation of law. If you are not the intended
> recipient, any disclosure, copying, forwarding or distribution of this email
> is strictly prohibited and this email and any attachments should be deleted
> immediately. This email and any attachments do not constitute an offer to
> sell or a solicitation of an offer to purchase any interest in any
> investment vehicle sponsored by Moon Capital Management LP (“Moon Capital”).
> Moon Capital does not provide legal, accounting or tax advice. Any statement
> regarding legal, accounting or tax matters was not intended or written to be
> relied upon by any person as advice. Moon Capital does not waive
> confidentiality or privilege as a result of this email.
>
>
>
>
Re: Batch update efficiency with composite key
Posted by Kirk True <ki...@mustardgrain.com>.
I was aware of the read-then-write pattern for counters, but not
secondary indexes. I'll have to take a look into that.
Thanks.
On 07/20/2012 02:32 AM, aaron morton wrote:
> I'm assuming the logical row is in a CQL 3 CF with composite
> PRIMARYKEY http://www.datastax.com/dev/blog/whats-new-in-cql-3-0
>
> It will still be a no look write. The exception being secondary
> indexes and counters which include reads in the write path.
>
> Cheers
>
> -----------------
> Aaron Morton
> Freelance Developer
> @aaronmorton
> http://www.thelastpickle.com
>
> On 20/07/2012, at 10:26 AM, Kirk True wrote:
>
>> In Cassandra you don't read-then-write updates, you just write the
>> updates.
>>
>> Sorry for being dense, but can you clarify a logical vs. physical row?
>>
>> Batching is useful for reducing round trips to the server.
>>
>> On 07/18/2012 06:18 AM, Leonid Ilyevsky wrote:
>>>
>>> I have a question about efficiency of updates to a CF with composite
>>> key.
>>>
>>> Let say I have 100 of logical rows to update, and they all belong to
>>> the same physical wide row. In my naïve understanding (correct me if
>>> I am wrong), in order to update a logical row, Cassandra has to
>>> retrieve the whole physical row, add columns to it, and put it back.
>>> So I put all my 100 updates in a batch and send it over. Would
>>> Cassandra be smart enough to recognize that they all belong to one
>>> physical row, retrieve it once, do all the updates and put it back
>>> once? Is my batch thing even relevant in this case? What happens if
>>> I just send updates one by one?
>>>
>>> I want to understand why I should use batches. I don’t really care
>>> about one timestamp for all records, I only care about efficiency.
>>> So I thought, I want to at least save on the number of remote calls,
>>> but I also wonder what happens on Cassandra side.
>>>
>>>
>>> ------------------------------------------------------------------------
>>> This email, along with any attachments, is confidential and may be
>>> legally privileged or otherwise protected from disclosure. Any
>>> unauthorized dissemination, copying or use of the contents of this
>>> email is strictly prohibited and may be in violation of law. If you
>>> are not the intended recipient, any disclosure, copying, forwarding
>>> or distribution of this email is strictly prohibited and this email
>>> and any attachments should be deleted immediately. This email and
>>> any attachments do not constitute an offer to sell or a solicitation
>>> of an offer to purchase any interest in any investment vehicle
>>> sponsored by Moon Capital Management LP (“Moon Capital”). Moon
>>> Capital does not provide legal, accounting or tax advice. Any
>>> statement regarding legal, accounting or tax matters was not
>>> intended or written to be relied upon by any person as advice. Moon
>>> Capital does not waive confidentiality or privilege as a result of
>>> this email.
>>
>
Re: Batch update efficiency with composite key
Posted by aaron morton <aa...@thelastpickle.com>.
I'm assuming the logical row is in a CQL 3 CF with composite PRIMARYKEY http://www.datastax.com/dev/blog/whats-new-in-cql-3-0
It will still be a no look write. The exception being secondary indexes and counters which include reads in the write path.
Cheers
-----------------
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com
On 20/07/2012, at 10:26 AM, Kirk True wrote:
> In Cassandra you don't read-then-write updates, you just write the updates.
>
> Sorry for being dense, but can you clarify a logical vs. physical row?
>
> Batching is useful for reducing round trips to the server.
>
> On 07/18/2012 06:18 AM, Leonid Ilyevsky wrote:
>> I have a question about efficiency of updates to a CF with composite key.
>>
>> Let say I have 100 of logical rows to update, and they all belong to the same physical wide row. In my naïve understanding (correct me if I am wrong), in order to update a logical row, Cassandra has to retrieve the whole physical row, add columns to it, and put it back. So I put all my 100 updates in a batch and send it over. Would Cassandra be smart enough to recognize that they all belong to one physical row, retrieve it once, do all the updates and put it back once? Is my batch thing even relevant in this case? What happens if I just send updates one by one?
>>
>> I want to understand why I should use batches. I don’t really care about one timestamp for all records, I only care about efficiency. So I thought, I want to at least save on the number of remote calls, but I also wonder what happens on Cassandra side.
>>
>>
>> This email, along with any attachments, is confidential and may be legally privileged or otherwise protected from disclosure. Any unauthorized dissemination, copying or use of the contents of this email is strictly prohibited and may be in violation of law. If you are not the intended recipient, any disclosure, copying, forwarding or distribution of this email is strictly prohibited and this email and any attachments should be deleted immediately. This email and any attachments do not constitute an offer to sell or a solicitation of an offer to purchase any interest in any investment vehicle sponsored by Moon Capital Management LP (“Moon Capital”). Moon Capital does not provide legal, accounting or tax advice. Any statement regarding legal, accounting or tax matters was not intended or written to be relied upon by any person as advice. Moon Capital does not waive confidentiality or privilege as a result of this email.
>
Re: Batch update efficiency with composite key
Posted by Kirk True <ki...@mustardgrain.com>.
In Cassandra you don't read-then-write updates, you just write the updates.
Sorry for being dense, but can you clarify a logical vs. physical row?
Batching is useful for reducing round trips to the server.
On 07/18/2012 06:18 AM, Leonid Ilyevsky wrote:
>
> I have a question about efficiency of updates to a CF with composite key.
>
> Let say I have 100 of logical rows to update, and they all belong to
> the same physical wide row. In my naïve understanding (correct me if I
> am wrong), in order to update a logical row, Cassandra has to retrieve
> the whole physical row, add columns to it, and put it back. So I put
> all my 100 updates in a batch and send it over. Would Cassandra be
> smart enough to recognize that they all belong to one physical row,
> retrieve it once, do all the updates and put it back once? Is my batch
> thing even relevant in this case? What happens if I just send updates
> one by one?
>
> I want to understand why I should use batches. I don't really care
> about one timestamp for all records, I only care about efficiency. So
> I thought, I want to at least save on the number of remote calls, but
> I also wonder what happens on Cassandra side.
>
>
> ------------------------------------------------------------------------
> This email, along with any attachments, is confidential and may be
> legally privileged or otherwise protected from disclosure. Any
> unauthorized dissemination, copying or use of the contents of this
> email is strictly prohibited and may be in violation of law. If you
> are not the intended recipient, any disclosure, copying, forwarding or
> distribution of this email is strictly prohibited and this email and
> any attachments should be deleted immediately. This email and any
> attachments do not constitute an offer to sell or a solicitation of an
> offer to purchase any interest in any investment vehicle sponsored by
> Moon Capital Management LP ("Moon Capital"). Moon Capital does not
> provide legal, accounting or tax advice. Any statement regarding
> legal, accounting or tax matters was not intended or written to be
> relied upon by any person as advice. Moon Capital does not waive
> confidentiality or privilege as a result of this email.
Batch update efficiency with composite key
Posted by Leonid Ilyevsky <li...@mooncapital.com>.
I have a question about efficiency of updates to a CF with composite key.
Let say I have 100 of logical rows to update, and they all belong to the same physical wide row. In my naïve understanding (correct me if I am wrong), in order to update a logical row, Cassandra has to retrieve the whole physical row, add columns to it, and put it back. So I put all my 100 updates in a batch and send it over. Would Cassandra be smart enough to recognize that they all belong to one physical row, retrieve it once, do all the updates and put it back once? Is my batch thing even relevant in this case? What happens if I just send updates one by one?
I want to understand why I should use batches. I don't really care about one timestamp for all records, I only care about efficiency. So I thought, I want to at least save on the number of remote calls, but I also wonder what happens on Cassandra side.
________________________________
This email, along with any attachments, is confidential and may be legally privileged or otherwise protected from disclosure. Any unauthorized dissemination, copying or use of the contents of this email is strictly prohibited and may be in violation of law. If you are not the intended recipient, any disclosure, copying, forwarding or distribution of this email is strictly prohibited and this email and any attachments should be deleted immediately. This email and any attachments do not constitute an offer to sell or a solicitation of an offer to purchase any interest in any investment vehicle sponsored by Moon Capital Management LP ("Moon Capital"). Moon Capital does not provide legal, accounting or tax advice. Any statement regarding legal, accounting or tax matters was not intended or written to be relied upon by any person as advice. Moon Capital does not waive confidentiality or privilege as a result of this email.
Re: Replication factor - Consistency Questions
Posted by aaron morton <aa...@thelastpickle.com>.
> But isn't QUORUM on a 2-node cluster still 2 nodes?
Yes.
3 is where you start to get some redundancy - http://thelastpickle.com/2011/06/13/Down-For-Me/
Cheers
-----------------
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com
On 20/07/2012, at 10:24 AM, Kirk True wrote:
> But isn't QUORUM on a 2-node cluster still 2 nodes?
>
> On 07/17/2012 11:50 PM, Jason Tang wrote:
>> Yes, for ALL, it is not good for HA, and because we meet problem when use QUORAM, and current solution is switch Write:QUORAM / Read:QUORAM when got "UnavailableException" exception.
>>
>> 2012/7/18 Jay Parashar <jp...@itscape.com>
>> Thanks..but write ALL will fail for any downed nodes. I am thinking of QUORAM.
>>
>>
>> From: Jason Tang [mailto:ares.tang@gmail.com]
>> Sent: Tuesday, July 17, 2012 8:24 PM
>> To: user@cassandra.apache.org
>> Subject: Re: Replication factor - Consistency Questions
>>
>>
>> Hi
>>
>>
>> I am starting using Cassandra for not a long time, and also have problems in consistency.
>>
>>
>> Here is some thinking.
>>
>> If you have Write:Any / Read:One, it will have consistency problem, and if you want to repair, check your schema, and check the parameter "Read repair chance: "
>>
>> http://wiki.apache.org/cassandra/StorageConfiguration
>>
>>
>> And if you want to get consistency result, my suggestion is to have Write:ALL / Read:One, since for Cassandra, write is more faster then read.
>>
>>
>> For performance impact, you need to test your traffic, and if your memory can not cache all your data, or your network is not fast enough, then yes, it will impact to write one more node.
>>
>>
>> BRs
>>
>>
>> 2012/7/18 Jay Parashar <jp...@itscape.com>
>>
>> Hello all,
>>
>> There is a lot of material on Replication factor and Consistency level but I
>> am a little confused by what is happening on my setup. (Cassandra 1.1.2). I
>> would appreciate any answers.
>>
>> My Setup: A cluster of 2 nodes evenly balanced. My RF =2, Consistency Level;
>> Write = ANY and Read = 1
>>
>> I know that my consistency is Weak but since my RF = 2, I thought data would
>> be just duplicated in both the nodes but sometimes, querying does not give
>> me the correct (or gives partial) results. In other times, it gives me the
>> right results
>> Is the Read Repair going on after the first query? But as RF = 2, data is
>> duplicated then why the repair?
>> Note: My query is done a while after the Writes so data should have been in
>> both the nodes. Or is this not the case (flushing not happening etc)?
>>
>> I am thinking of making the Write as 1 and Read as QUORAM so R + W > RF (1 +
>> 2 > 2) to give strong consistency. Will that affect performance a lot
>> (generally speaking)?
>>
>> Thanks in advance
>> Regards
>>
>> Jay
>>
>>
>>
>>
>
Re: Replication factor - Consistency Questions
Posted by Kirk True <ki...@mustardgrain.com>.
But isn't QUORUM on a 2-node cluster still 2 nodes?
On 07/17/2012 11:50 PM, Jason Tang wrote:
> Yes, for ALL, it is not good for HA, and because we meet problem when
> use QUORAM, and current solution is switch Write:QUORAM / Read:QUORAM
> when got "UnavailableException" exception.
>
> 2012/7/18 Jay Parashar <jparashar@itscape.com
> <ma...@itscape.com>>
>
> Thanks..but write ALL will fail for any downed nodes. I am
> thinking of QUORAM.
>
> *From:*Jason Tang [mailto:ares.tang@gmail.com
> <ma...@gmail.com>]
> *Sent:* Tuesday, July 17, 2012 8:24 PM
> *To:* user@cassandra.apache.org <ma...@cassandra.apache.org>
> *Subject:* Re: Replication factor - Consistency Questions
>
> Hi
>
> I am starting using Cassandra for not a long time, and also have
> problems in consistency.
>
> Here is some thinking.
>
> If you have Write:Any / Read:One, it will have consistency
> problem, and if you want to repair, check your schema, and check
> the parameter "Read repair chance: "
>
> http://wiki.apache.org/cassandra/StorageConfiguration
>
> And if you want to get consistency result, my suggestion is to
> have Write:ALL / Read:One, since for Cassandra, write is more
> faster then read.
>
> For performance impact, you need to test your traffic, and if your
> memory can not cache all your data, or your network is not fast
> enough, then yes, it will impact to write one more node.
>
> BRs
>
> 2012/7/18 Jay Parashar <jparashar@itscape.com
> <ma...@itscape.com>>
>
> Hello all,
>
> There is a lot of material on Replication factor and Consistency
> level but I
> am a little confused by what is happening on my setup. (Cassandra
> 1.1.2). I
> would appreciate any answers.
>
> My Setup: A cluster of 2 nodes evenly balanced. My RF =2,
> Consistency Level;
> Write = ANY and Read = 1
>
> I know that my consistency is Weak but since my RF = 2, I thought
> data would
> be just duplicated in both the nodes but sometimes, querying does
> not give
> me the correct (or gives partial) results. In other times, it
> gives me the
> right results
> Is the Read Repair going on after the first query? But as RF = 2,
> data is
> duplicated then why the repair?
> Note: My query is done a while after the Writes so data should
> have been in
> both the nodes. Or is this not the case (flushing not happening etc)?
>
> I am thinking of making the Write as 1 and Read as QUORAM so R + W
> > RF (1 +
> 2 > 2) to give strong consistency. Will that affect performance a lot
> (generally speaking)?
>
> Thanks in advance
> Regards
>
> Jay
>
>
Re: Replication factor - Consistency Questions
Posted by Jason Tang <ar...@gmail.com>.
Yes, for ALL, it is not good for HA, and because we meet problem when use
QUORAM, and current solution is switch Write:QUORAM / Read:QUORAM when got
"UnavailableException" exception.
2012/7/18 Jay Parashar <jp...@itscape.com>
> Thanks..but write ALL will fail for any downed nodes. I am thinking of
> QUORAM.****
>
> ** **
>
> *From:* Jason Tang [mailto:ares.tang@gmail.com]
> *Sent:* Tuesday, July 17, 2012 8:24 PM
> *To:* user@cassandra.apache.org
> *Subject:* Re: Replication factor - Consistency Questions****
>
> ** **
>
> Hi****
>
> ** **
>
> I am starting using Cassandra for not a long time, and also have problems
> in consistency.****
>
> ** **
>
> Here is some thinking.****
>
> If you have Write:Any / Read:One, it will have consistency problem, and if
> you want to repair, check your schema, and check the parameter "Read repair
> chance: "****
>
> http://wiki.apache.org/cassandra/StorageConfiguration ****
>
> ** **
>
> And if you want to get consistency result, my suggestion is to have
> Write:ALL / Read:One, since for Cassandra, write is more faster then read.
> ****
>
> ** **
>
> For performance impact, you need to test your traffic, and if your memory
> can not cache all your data, or your network is not fast enough, then yes,
> it will impact to write one more node.****
>
> ** **
>
> BRs****
>
> ** **
>
> 2012/7/18 Jay Parashar <jp...@itscape.com>****
>
> Hello all,
>
> There is a lot of material on Replication factor and Consistency level but
> I
> am a little confused by what is happening on my setup. (Cassandra 1.1.2). I
> would appreciate any answers.
>
> My Setup: A cluster of 2 nodes evenly balanced. My RF =2, Consistency
> Level;
> Write = ANY and Read = 1
>
> I know that my consistency is Weak but since my RF = 2, I thought data
> would
> be just duplicated in both the nodes but sometimes, querying does not give
> me the correct (or gives partial) results. In other times, it gives me the
> right results
> Is the Read Repair going on after the first query? But as RF = 2, data is
> duplicated then why the repair?
> Note: My query is done a while after the Writes so data should have been in
> both the nodes. Or is this not the case (flushing not happening etc)?
>
> I am thinking of making the Write as 1 and Read as QUORAM so R + W > RF (1
> +
> 2 > 2) to give strong consistency. Will that affect performance a lot
> (generally speaking)?
>
> Thanks in advance
> Regards
>
> Jay
>
> ****
>
> ** **
>
RE: Replication factor - Consistency Questions
Posted by Jay Parashar <jp...@itscape.com>.
Thanks..but write ALL will fail for any downed nodes. I am thinking of
QUORAM.
From: Jason Tang [mailto:ares.tang@gmail.com]
Sent: Tuesday, July 17, 2012 8:24 PM
To: user@cassandra.apache.org
Subject: Re: Replication factor - Consistency Questions
Hi
I am starting using Cassandra for not a long time, and also have problems in
consistency.
Here is some thinking.
If you have Write:Any / Read:One, it will have consistency problem, and if
you want to repair, check your schema, and check the parameter "Read repair
chance: "
http://wiki.apache.org/cassandra/StorageConfiguration
And if you want to get consistency result, my suggestion is to have
Write:ALL / Read:One, since for Cassandra, write is more faster then read.
For performance impact, you need to test your traffic, and if your memory
can not cache all your data, or your network is not fast enough, then yes,
it will impact to write one more node.
BRs
2012/7/18 Jay Parashar <jp...@itscape.com>
Hello all,
There is a lot of material on Replication factor and Consistency level but I
am a little confused by what is happening on my setup. (Cassandra 1.1.2). I
would appreciate any answers.
My Setup: A cluster of 2 nodes evenly balanced. My RF =2, Consistency Level;
Write = ANY and Read = 1
I know that my consistency is Weak but since my RF = 2, I thought data would
be just duplicated in both the nodes but sometimes, querying does not give
me the correct (or gives partial) results. In other times, it gives me the
right results
Is the Read Repair going on after the first query? But as RF = 2, data is
duplicated then why the repair?
Note: My query is done a while after the Writes so data should have been in
both the nodes. Or is this not the case (flushing not happening etc)?
I am thinking of making the Write as 1 and Read as QUORAM so R + W > RF (1 +
2 > 2) to give strong consistency. Will that affect performance a lot
(generally speaking)?
Thanks in advance
Regards
Jay
Re: Replication factor - Consistency Questions
Posted by Jason Tang <ar...@gmail.com>.
Hi
I am starting using Cassandra for not a long time, and also have problems
in consistency.
Here is some thinking.
If you have Write:Any / Read:One, it will have consistency problem, and if
you want to repair, check your schema, and check the parameter "Read repair
chance: "
http://wiki.apache.org/cassandra/StorageConfiguration
And if you want to get consistency result, my suggestion is to have
Write:ALL / Read:One, since for Cassandra, write is more faster then read.
For performance impact, you need to test your traffic, and if your memory
can not cache all your data, or your network is not fast enough, then yes,
it will impact to write one more node.
BRs
2012/7/18 Jay Parashar <jp...@itscape.com>
> Hello all,
>
> There is a lot of material on Replication factor and Consistency level but
> I
> am a little confused by what is happening on my setup. (Cassandra 1.1.2). I
> would appreciate any answers.
>
> My Setup: A cluster of 2 nodes evenly balanced. My RF =2, Consistency
> Level;
> Write = ANY and Read = 1
>
> I know that my consistency is Weak but since my RF = 2, I thought data
> would
> be just duplicated in both the nodes but sometimes, querying does not give
> me the correct (or gives partial) results. In other times, it gives me the
> right results
> Is the Read Repair going on after the first query? But as RF = 2, data is
> duplicated then why the repair?
> Note: My query is done a while after the Writes so data should have been in
> both the nodes. Or is this not the case (flushing not happening etc)?
>
> I am thinking of making the Write as 1 and Read as QUORAM so R + W > RF (1
> +
> 2 > 2) to give strong consistency. Will that affect performance a lot
> (generally speaking)?
>
> Thanks in advance
> Regards
>
> Jay
>
>
>