Skip to main content
JB0000000000001
Gold ⭐️
May 19, 2021 11:04 AM UTC
Solved

simplest method to read a full hbase table so it is stored in the cache

Dear Experts,
I am interested in accessing all the data in a hbase table once, so it will be cached.
I am using an application that reads from hbase and I notice it is a lot faster when the data was read before, so I would like to "preheat" the data by warming it up: accessing it all once, so it is stored in the cache.
I am quite familiar with the cluster configuration necessary to enable caching but wonder what is the easiest way to do this.
Is there a command that accesses all the data in all regions 1x?


 

smdas
smdasAnswer
Gold ⭐️⭐️
May 21, 2021 8:51 PM UTC

Hello @JB0000000000001 

 

Appreciate your detailed response. To some of your reviews,

  • To check upon the Impact of Row Counter on Caching, Created a Table on a Vanilla HBase Setup, Executed PE Write to insert 100,000 Rows. Flush & Restarted the Service to ensure there is no WAL Split write going through the MemStore, thereby assisting in Read Access. As shown below, there is no Read & Write with Server Metrics showing 4 Blocks of 400KB Size in Block Cache:

Before_RowCounter_1.pngBefore_RowCounter_2.png

  • After a RowCounter Job, We observed ~100,000 Reads with Used Heap increased around ~150MB yet Block Cache Size remained Similar.

After_RowCounter_1.pngAfter_RowCounter_2.png

  • After a Scan Operation reading each of the 100,000 Rows, the Read Request increased by 100,000 & the Block Cache Sizing increased by ~100MB & Block Count increasing by ~1500 & Hit Ration further deteriorating owing to larger Misses:

After_Scan_1.pngAfter_Scan_2.png

  • Row Counter likely doesn't offer Caching benefits yet I have shared our Observation to ensure you can compare the same with your observation as well.
  • Using the Region Server Grouping would still involve Eviction, yet the Competition & Quantity of Objects for Cache would be reduced by reducing the Tables involved within the RS Grouping Scope. This might be a bit Excessive approach yet I thought of sharing the same, in case you may wish to review.
  • The Link [1] has the required Map Reduce Programs & I couldn't find anyone, which may fit the Use-Case of access all Data 1x. A Full Table Scan can be likely equivalent to running a Scan on HBase Shell for the Table. Or, Phoenix for SQL approach may be considered by you yet I believe writing a SELECT SQL using FTS is equivalent to Scanning the HBase Table via "scan".
  • Link [2] does mention In-Memory Column Family are the last to evict, yet there's no guarantee that In-Memory Column Family would always remain in Memory.
  • Also, I see you have "CACHE_INDEX_ON_WRITE" as True. So, I assume you might be extracting the most from your Memory unless Caching Policies possibility. While I haven't tested, Sharing Link [3] which talks about the various Caching Policies Test for Block Cache.

While I couldn't find any 100% guaranteed way to Cache the Objects, I believe you have implemented the most such functionalities already as discussed until now. I fear Compression & Encoding may not be helpful as Data is always Decompressed in Memory, likely leaving the possibility of reviewing the Caching Policies. I may have missed other possibilities & would share, if I come across any.

 

- Smarak

 

[1] https://hbase.apache.org/book.html#hbase.mapreduce.classpath

[2] https://hbase.apache.org/book.html#block.cache.design

[3] https://blogs.apache.org/hbase/entry/comparing_blockcache_deploys

 

 

8 replies

JB0000000000001
Gold ⭐️
May 19, 2021 3:50 PM UTC

I have the feeling this is a good guess:
hbase org.apache.hadoop.hbase.mapreduce.RowCounter
It counts rows, but not entirely sure it will cache everything.

Translate
smdas
Gold ⭐️⭐️
Gold ⭐️⭐️
May 21, 2021 9:57 AM UTC

Hello @JB0000000000001 

 

Thanks for using Cloudera Community. You wish to store a Table in Cache via a Read-Once Model. 

 

  • As you stated, RowCounter would count the Rows & skip caching the data in the Cache as well,
  • Even if you have a Block Cache configured with sufficient capacity to manage the Table's Data into the Cache, their LRU implementation would likely cause the Object to be evicted. I haven't used any other Cache implementation outside of LRU to comment. 
  • If you have a Set of Tables meeting such requirement, We can use RegionServer Grouping for the concerned Table's Region & ensure the BlockCache of the concerned RegionServer Group is used for Selective Tables' Regions, thereby reducing the impact of LRU. 
  • Test using the "IN_MEMORY" Flag for the Table's Column Families, which would try to persist the Column's Family Data as long as it can without any guarantee. 
  • While an Old Blog, yet [1] offers a few Practices implemented by a Heavy-HBase-Using Customer of Cloudera, written by their Employees' experience. As you are already familiar with various Heap Option, there may be no new Information for you yet I am sharing for closing any loop. 

Hope the above helps. Do let us know if your Team implemented any approach so as to benefit the wider audience looking at Similar Use-Case.

 

- Smarak

 

[1] http://blog.asquareb.com/blog/2014/11/21/leverage-hbase-cache-and-improve-read-performance/

Translate
smdas
Gold ⭐️⭐️
Gold ⭐️⭐️
May 27, 2021 5:52 AM UTC

Hello @JB0000000000001 

 

Unfortunately, I didn't find any 1 Document explaining the HMaster UI Metrics collectively. Let me know if you come across any Metrics, which isn't clear. I shall review the same & share the required details. If I can't help, I shall ensure I get the required details from our Product Engineering Team to assist as well. 

 

- Smarak

Translate