Cassandra Counters and Replication Factor
Hi, Looking at this talk ( http://www.datastax.com/wp-content/uploads/2011/07/cassandra_sf_counters.pdf) by Sylvain Lesbresne at DataStax, I had a few questions related to my understanding Cassandra architecture. Assuming that we have a keyspace in Cassandra with: 1. Replication Factor (RF) = 1. 2. "Counters" as a counter column family having "row-key" as a row key which has "cnt" as a counter column. 3. We always update Counters["row-key"]["cnt"] with a Consistency level of ONE. My understanding is that in such a case, the updates/second of that counter will be limited by the performance of just one node in the cluster. Adding new nodes will not increase the rate of update. However if RF was 3 (keeping everything else same), updates/second would roughly have been 3 times the current value. Am I correct here? Moreover, any write operation to a column in a key in the above mentioned configuration can scale only if RF increases. Is this inference correct? -- Regards Amit S. Chavan
Re: Cassandra Counters and TTL
Answers inline. On Fri, Nov 4, 2011 at 4:59 PM, Vlad Paiu wrote: > Hello, > > I'm a new user of Cassandra and I think it's great. > Still, while developing my APP using Cassandra, I got stuck with some > things and I'm not really sure that Cassandra can handle them at the moment. > > So, first of all, does Cassandra allow for Counters and regular Keys to be > located in the same ColumnFamily ? > What do you mean when you say "regular Keys"? If you are hinting at columns apart from counters, then the answer is *no*: only counters can exist in a CounterColumnFamily and other column families cannot hold counters. > > Secondly, is there any way to dynamically set the TTL for a key ? In the > sense that I have a key, I initially set it with no TTL, but after a while > I decide that it should expire in 100 seconds. Can Cassandra do this ? > TTL is not for one key, it is for one column. > > 3. Can counters have a TTL ? > No. Currently, counters do not (or if I am correct - cannot) have TTL. > > 4. Is there any way to atomically reset a counter ? I read on the website > that the only way to do it is read the variable value, and then set it to > -value, which seems rather bogus to me. > I think that is the only way to reset a counter. I would like to know if there is another way. Background: I am using Cassandra since the past two months. Hope the community corrects me if I am wrong. > > Regards, > > -- > Vlad Paiu > OpenSIPS Developer > > -- Regards Amit S. Chavan
Write latency of counter updates across multiple rows
Hi, In our use case, we maintain minute-wise roll ups for different metrics. These are stored in a counter column family where the row key is a composite containing the timestamp rounded to the last minute and an integer between 0-9 (This integer is calculated as the MD5 hash of the metric mod 10). The column names are the metrics we wish to track. Typically, each row has about 100,000 counters. We tested two scenarios. The first one is as mentioned above. In this case we got a per write latency of about 80 micro-seconds to 100 micro-seconds. In the other scenario, we calculated the integer in the row key as mod 100. In this case we observed a per write latency of 50 micro-seconds to 70 micro-seconds. I wish to understand why updates to counters were faster as they got spread across multiple rows? Cluster summary : 4 nodes running Cassandra 1.0.5. Each with 8 cores, 32G RAM, 10G Cassandra heap. We are using replication factor of 2. -- Thanks! Amit Chavan