peter.petrov
peter.petrov

Reputation: 39477

Counter Read/Increment in HBase

I want to store a counter (per key) in an HBase table (in an AWS EMR cluster). The key of the table will be some sort of ID.

Then an AWS lambda function would read (by ID) that counter, and would increment the counter (that corresponds to that ID).

Of course there could be multiple concurrent executions of this lambda function so multiple processes/threads could be accessing the same ID at the same time and trying to increment the same counter (for that ID).

OK, but AWS lambda is a serverless technology, so I have no way to sync/serialize any concurrent (read counter, increment counter) operations and make this pair of operations atomic.

So what is the best approach in this case?

How do I make sure my counter is always read and updated correctly (in a consistent, atomic way) so that the counter's final value is correct?

Is HBase even good for keeping this kind of counter?

Alternative solutions and suggestions are also welcome. But if it can be done just with an HBase table and with AWS lambda that would be great.

Upvotes: 0

Views: 34

Answers (0)

Related Questions