Read Before Writes on Distributed Counters

Russell Brown russell.brown at mac.com
Thu Oct 17 13:03:10 EDT 2013


On 17 Oct 2013, at 17:21, Jeremiah Peschka <jeremiah.peschka at gmail.com> wrote:

> When you 'update' a counter, you send in an increment operation. That's added to an internal list in Riak. The operations are then zipped up to provide the correct counter value on read. The worst that you'll do is add a large(ish) number of values to the op list inside Riak. 

Just to borrow some Cribbs-brand pedantry here:- That isn't true. We read the data from disk, increment an entry in what is essentially a version vector, and write it back, (then replicate the result to N-1 vnodes.) The size of the counter depends on the number of actors that have incremented it (typically N) not the number of operations.

> 
> Siblings will be created, but they will not be visible to the end user who is reading from the counter.

There won't be siblings on disk (we do create a temporary one in memory, does that count?) _unless_

1. you also write an object to that same key in a normal riak kv  way (don't do that)
2. AAE or MDC cause a sibling to be created (this is because we use the operation of incrementing a counter to identify a key as counter, to the rest of riak it is just a riak object)

In that last case, an increment operation to the key will resolve the sibling(s).

Cheers

Russell

> 
> Check out this demo of the new counter types from Sean Cribbs: https://vimeo.com/43903960
> 
> ---
> Jeremiah Peschka - Founder, Brent Ozar Unlimited
> MCITP: SQL Server 2008, MVP
> Cloudera Certified Developer for Apache Hadoop
> 
> 
> On Thu, Oct 17, 2013 at 9:55 AM, Daniil Churikov <ddosia at gmail.com> wrote:
> Correct me if I wrong, but when you blindly do update without previous read,
> you create a sibling, which should be resolved on read. In case if you make
> a lot of increments for counter and rarely reads it will lead to siblings
> explosion.
> 
> I am not familiar with new counters datatypes, so I am curious.
> 
> 
> 
> --
> View this message in context: http://riak-users.197444.n3.nabble.com/Read-Before-Writes-on-Distributed-Counters-tp4029492p4029498.html
> Sent from the Riak Users mailing list archive at Nabble.com.
> 
> _______________________________________________
> riak-users mailing list
> riak-users at lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
> 
> _______________________________________________
> riak-users mailing list
> riak-users at lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com





More information about the riak-users mailing list