Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
HBase >> mail # user >> Timestamp as a key good practice?


Copy link to this message
-
Re: Timestamp as a key good practice?
Actually I think you should revisit your key design....

Look at your access path to the data for each of the types of queries you are going to run.
From your post:
"I have a table with a uniq key, a file path and a "last update" field.
>>> I can easily find back the file with the ID and find when it has been
>>> updated.
>>>
>>> But what I need too is to find the files not updated for more than a
>>> certain period of time.
"
So your primary query is going to be against the key.
Not sure if you meant to say that your key was a composite key or not... sounds like your key is just the unique key and the rest are columns in the table.

The secondary query or path to the data is to find data where the files were not updated for more than a period of time.

If you make your key temporal, that is adding time as a component of your key, you will end up creating new rows of data while the old row still exists.
Not a good side effect.

The other nasty side effect of using time as your key is that you not only have the potential for hot spotting, but that you also have the nasty side effect of creating splits that will never grow.

How often are you going to ask to see the files where they were not updated in the last couple of days/minutes? If its infrequent, then you really should care if you have to do a complete table scan.
On Jun 14, 2012, at 5:39 AM, Jean-Marc Spaggiari wrote:

> Wow! This is exactly what I was looking for. So I will read all of that now.
>
> Need to read here at the bottom: https://github.com/sematext/HBaseWD
> and here: http://blog.sematext.com/2012/04/09/hbasewd-avoid-regionserver-hotspotting-despite-writing-records-with-sequential-keys/
>
> Thanks,
>
> JM
>
> 2012/6/14, Otis Gospodnetic <[EMAIL PROTECTED]>:
>> JM, have a look at https://github.com/sematext/HBaseWD (this comes up
>> often.... Doug, maybe you could add it to the Ref Guide?)
>>
>> Otis
>> ----
>> Performance Monitoring for Solr / ElasticSearch / HBase -
>> http://sematext.com/spm
>>
>>
>>
>>> ________________________________
>>> From: Jean-Marc Spaggiari <[EMAIL PROTECTED]>
>>> To: [EMAIL PROTECTED]
>>> Sent: Wednesday, June 13, 2012 12:16 PM
>>> Subject: Timestamp as a key good practice?
>>>
>>> I watched Lars George's video about HBase and read the documentation
>>> and it's saying that it's not a good idea to have the timestamp as a
>>> key because that will always load the same region until the timestamp
>>> reach a certain value and move to the next region (hotspotting).
>>>
>>> I have a table with a uniq key, a file path and a "last update" field.
>>> I can easily find back the file with the ID and find when it has been
>>> updated.
>>>
>>> But what I need too is to find the files not updated for more than a
>>> certain period of time.
>>>
>>> If I want to retrieve that from this single table, I will have to do a
>>> full parsing of the table. Which might take a while.
>>>
>>> So I thought of building a table to reference that (kind of secondary
>>> index). The key is the "last update", one FC and each column will have
>>> the ID of the file with a dummy content.
>>>
>>> When a file is updated, I remove its cell from this table, and
>>> introduce a new cell with the new timestamp as the key.
>>>
>>> And so one.
>>>
>>> With this schema, I can find the files by ID very quickly and I can
>>> find the files which need to be updated pretty quickly too. But it's
>>> hotspotting one region.
>>>
>>> From the video (0:45:10) I can see 4 situations.
>>> 1) Hotspotting.
>>> 2) Salting.
>>> 3) Key field swap/promotion
>>> 4) Randomization.
>>>
>>> I need to avoid hostpotting, so I looked at the 3 other options.
>>>
>>> I can do salting. Like prefix the timestamp with a number between 0
>>> and 9. So that will distribut the load over 10 servers. To find all
>>> the files with a timestamp below a specific value, I will need to run
>>> 10 requests instead of one. But when the load will becaume to big for
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB