gphilip
gphilip

Reputation: 706

Using HBase for analytics

I'm almost completely new to HBase. I would like to take my current site tracking based on MySQL and put it to HBase because MySQL simply doesn't scale anymore.

I'm totally lost int eh first step...

I need to track different actions of users and need to be able to aggregate them by some aspects (date, country they come from, product they performed the action with, etc...)

The way I store it currently is that I have a table with a composite PK with all these aspects (country, date, product, ...) and the rest of the fields are counters for actions. When an action is performed, I insert it to the table incrementing the action's column by one (ON DUPLICATE KEY UPDATE...).

*date      | *country | *product | visited | liked | put_to_basket | purchased
2011-11-11 | US       | 123      | 2       | 1     | 0             | 0
2011-11-11 | GB       | 123      | 23      | 10    | 5             | 4
2011-11-12 | GB       | 555      | 54      | 0     | 10            | 2

I have a feeling that this is completely against the HBase way, and also doesn't really scale (with the growing number if keys inserts get expensive) and not really flexible.

How to track user actions with it attributes effectively in HBase? How table(s) should look like? Where MapReduce comes in the picture?

Thanks for all suggestions!

Upvotes: 2

Views: 1642

Answers (2)

sriram
sriram

Reputation: 732

This can be done as follows,

Have the unique row id in Hbase as follows,

rowid = date + country + product ---> append these into a single entity and have it as key.

Then have the counters as columns. So when you get an event like,

if(event == liked){
increment the liked column of the hbase by 1 for the corresponding key combination.
}

and so on for other cases.

Hope this helps!!

Upvotes: 1

Arnon Rotem-Gal-Oz
Arnon Rotem-Gal-Oz

Reputation: 25909

Lars George's "HBASE: the definitive guide" explains a design very similar to what you want to achieve in the introduction chapter

Upvotes: 1

Related Questions