At this point, you have determined that you have enough physical memory on your servers to extend BlockCache beyond the JVM Heap. You have configured values for the JVM heap, LruBlockCache, and MemStore (shown in Figure 2, copied here for reference).
Next, configure and enable BucketCache. To do this, note the memory specifications and values in Configuring BlockCache, plus a few additional values shown in Figure 3 and in the following table.
Figure 3. Configuring BucketCache
In the following table, the first column refers to the elements in Figure 3. The second column describes each element and, if applicable, its associated variable or property name. The third column contains values and formulas.
The fourth column computes values based on the following sample configuration parameters:
128 GB for the RegionServer process (there is additional memory available for other HDP processes)
Workload consists of 75% reads, 25% writes.
HBASE_HEAPSIZE
= 20 GB (20480 MB)
Note | |
---|---|
Most of the following values are specified in megabytes; three are proportions. |
Item |
Description |
Value or Formula |
Example |
A |
Total physical memory for RegionServer operations: on-heap plus off-heap ("direct") memory (MB) |
(hardware dependent) |
131072 |
B* |
|
Recommendation: 20480 |
20480 |
C |
|
A - B |
131072 - 20480 = 110592 |
Dp* |
|
(proportion of reads) * 0.8 |
0.75 * 0.8 = 0.6 |
Dm |
Maximum amount of JVM heap to allocate to BlockCache (MB) |
B * Dp |
20480 * 0.6 = 12288 |
Ep* |
|
0.8 - Dp |
0.8 - 0.6 = 0.2 |
F |
Amount of off-heap memory to reserve for other uses (DFSClient; MB) |
Recommendation: 1024 to 2048 |
2048 |
G |
Amount of off-heap memory to allocate to BucketCache (MB) |
C - F |
110592 - 2048 = 108544 |
|
|
Dm + G |
12288 + 108544 = 120832 |
|
|
G / (Dm + G) |
108544 / 120832 = 0.89830508474576 |
* Specified in Configuring BlockCache
After completing the steps in Configuring BlockCache, follow these steps to configure BucketCache.
In the
hbase-env.sh
file for each RegionServer, or in thehbase-env.sh
file supplied to Ambari, set the-XX:MaxDirectMemorySize
argument forHBASE_REGIONSERVER_OPTS
to the amount of direct memory you wish to allocate to HBase. In the sample configuration, the value would be110592m
. (-XX:MaxDirectMemorySize
accepts a number followed by a unit indicator;m
indicates megabytes.)HBASE_OPTS="$HBASE_OPTS -XX:MaxDirectMemorySize=110592m"
In the
hbase-site.xml
file, specify BucketCache size and percentage. For the sample configuration, the values would be120832
and0.89830508474576
, respectively. If you choose to round the proportion, round up. This will allocate space related to rounding error to the (larger) off-heap memory area.<property> <name>hbase.bucketcache.size</name> <value>120832</value> </property> <property> <name>hbase.bucketcache.percentage.in.combinedcache</name> <value>0.8984</value> </property>
In the
hbase-site.xml
file, sethbase.bucketcache.ioengine
tooffheap
. This enables BucketCache.<property> <name>hbase.bucketcache.ioengine</name> <value>offheap</value> </property>
Restart (or rolling restart) the cluster. It can take a minute or more to allocate BucketCache, depending on how much memory you are allocating. Check logs for error messages.