Cassandra / HBase or just MySQL: potential problems do the following

Say I have a "user". This is the key. And I need to save the "user counter". I plan to have an entry with the key "user" and the value "0" on "9999+ ;-)" (how much I will have).

What problems will I use if I use Cassandra, HBase or MySQL for this? Let's say I have thousands of new updates to this "user" key, where I need to increase the value. I have a problem's? Locked for recording? Any other way to do this?

Why this is done - there will be many "user" keys. Various other cases. But the idea is the same. Why keep it up, because I will have more readings, so I can always get the “calculated value” very quickly.

+4
source share
4 answers

I would just update the user account as a batch operation every N minutes, and not update it in real time. If there is only one update process, you do not need to worry about conflict by definition.

Alternatively, cassandra has a / mutex tab to add lock support through ZooKeeper.

+4
source

MongoDB has an in-place update and a special inc statement for counters. http://blog.mongodb.org/post/171353301/using-mongodb-for-real-time-analytics

+1
source

MongoDB and HBase have this built-in (like most other databases that guarantee consistency).

One pretty simple trick with Cassandra is to have a specific string for a user number, and then insert a unique unique identifier (like a random UUID) with an empty value in it every time a user is added. At regular intervals, count the number of columns and put them in a total counter - deleting the columns you just counted.

At any time, your total user count is therefore [total counter] + [the number of columns in your user count row]. You can get them essentially with two readings, and if you have line cache enabled, it will be fast.

+1
source

HBase has an incrementColumnValue method for a fast, atomic read / write operation.

0
source

Source: https://habr.com/ru/post/1305254/


All Articles