Thanks for the approach you suggested Asaf. This is definitely very promising. Our use case is that, we have a raw stream of events which may have duplicates. After our HBase + MR processing, we would emit a de-duped stream (which would have duplicates eliminated) for later processing. Let me see if I understand your approach correctly:
* During major compaction, we emit only the earliest event. I understand this.
* Between major compactions, we would need only return the earliest event in the scan. However, we would no longer take advantage of the timerange scan since we would need to consider previously compacted files as well(an earlier duplicate could exist in a previously major-compacted hfile, hence we need to skip returning this row in the scan). This would mean the scan would need to be a full - table scan or we perform an exists() call in the prescan hook for an earlier version of the row?
From: Asaf Mesika <[EMAIL PROTECTED]>
To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>; Rahul Ravindran <[EMAIL PROTECTED]>
Sent: Tuesday, June 4, 2013 10:51 PM
Subject: Re: Scan + Gets are disk bound
On Tuesday, June 4, 2013, Rahul Ravindran wrote:
>We are relatively new to Hbase, and we are hitting a roadblock on our scan performance. I searched through the email archives and applied a bunch of the recommendations there, but they did not improve much. So, I am hoping I am missing something which you could guide me towards. Thanks in advance.
>We are currently writing data and reading in an almost continuous mode (stream of data written into an HBase table and then we run a time-based MR on top of this Table). We currently were backed up and about 1.5 TB of data was loaded into the table and we began performing time-based scan MRs in 10 minute time intervals(startTime and endTime interval is 10 minutes). Most of the 10 minute interval had about 100 GB of data to process.
>Our workflow was to primarily eliminate duplicates from this table. We have maxVersions = 5 for the table. We use TableInputFormat to perform the time-based scan to ensure data locality. In the mapper, we check if there exists a previous version of the row in a time period earlier to the timestamp of the input row. If not, we emit that row.
If I understand correctly, for a rowkey R, column family F, column qualifier C, if you have two values with time stamp 13:00 and 13:02, you want to remove the value associated with 13:02.
The best way to do this is to write a simple RegionObserver Coprocessor, which hooks to the compaction process (preCompact for instance). In there simply, for any given R, F, C only emit the earliest timestamp value (the last, since timestamp is ordered descending), and that's it.
It's a very effective way, since you are "riding" on top of an existing process which reads the values either way, so you are not paying the price of reading it again your MR job.
Also, in between major compactions, you can also implement the preScan hook in the region observer, so you'll pick up only the earliest timestamp value, thus achieving the same result for your client, although you haven't removed those values yet.
I've implemented this for counters delayed aggregations, and it works great in production.
>We looked at https://issues.apache.org/jira/browse/HBASE-4683 and hence turned off block cache for this table with the expectation that the block index and bloom filter will be cached in the block cache. We expect duplicates to be rare and hence hope for most of these checks to be fulfilled by the bloom filter. Unfortunately, we notice very slow performance on account of being disk bound. Looking at jstack, we notice that most of the time, we appear to be hitting disk for the block index. We performed a major compaction and retried and performance improved some, but not by much. We are processing data at about 2 MB per second.
> We are using CDH 4.2.1 HBase 0.94.2 and HDFS 2.0.0 running with 8 datanodes/regionservers(each with 32 cores, 4x1TB disks and 60 GB RAM). HBase is running with 30 GB Heap size, memstore values being capped at 3 GB and flush thresholds being 0.15 and 0.2. Blockcache is at 0.5 of total heap size(15 GB). We are using SNAPPY for our tables.