Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBASE-28097 Add documentation section for the Cache Aware balancer fu… #5495

Merged
merged 2 commits into from
Nov 2, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/main/asciidoc/_chapters/architecture.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,48 @@ For a RegionServer hosting data that can comfortably fit into cache, or if your

The compressed BlockCache is disabled by default. To enable it, set `hbase.block.data.cachecompressed` to `true` in _hbase-site.xml_ on all RegionServers.

==== Cache Aware Load Balancer

HBase uses ephemeral cache to cache the blocks by reading them from the slow storages and storing them to the bucket cache. This cache is warmed up every time a region server is started. Depending on the data size and the configured cache size, the cache warm up can take anywhere from a few minutes to a few hours. Doing this everytime the region server starts can be a very expensive process. To eliminate this, link:https://issues.apache.org/jira/browse/HBASE-27313[HBASE-27313] implemented the cache persistence feature where the region servers periodically persist the blocks cached in the bucket cache. This persisted information is then used to resurrect the cache in the event of a region server restart because of normal restart or crash.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove this explanation: HBase uses ephemeral cache to cache the blocks by reading them from the slow storages and storing them to the bucket cache. This cache is warmed up every time a region server is started.

Also let's mention the importance of this when using cloud storage:

Depending on the data size and the configured cache size, the cache warm up can take anywhere from a few minutes to a few hours. This become even more critical for HBase deployments over cloud storage, where compute is separated from storage. Doing this everytime the region server starts can be a very expensive process.


link:https://issues.apache.org/jira/browse/HBASE-27999[HBASE-27999] implements the prefetch aware load balancer which is aimed at enhancing the capability of HBase to enable the balancer to consider the cache allocation of each region on region servers when calculating a new assignment plan and use the region/region server cache allocation information reported by region servers to calculate the percentage of HFiles cached for each region on the hosting server, and then use that as another factor when deciding on an optimal, new assignment plan.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some re-wording:

implements the cache aware load balancer, which adds to the load balancer the ability to consider the cache allocation of each region on region servers when calculating a new assignment plan, using the region/region server cache allocation information reported by region servers to calculate the percentage of HFiles cached for each region on the hosting server. This information is then used by the balancer as another factor when deciding on an optimal, new assignment plan.


The master node captures the prefetch information from all the region servers and uses this information to decide the region assignments while ensuring a minimal impact on the warmed up cache. A region is assigned to the region server where it has a better cache ratio as compared to the region server where it is currently hosted.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion:

The master node captures the caching information from all the region servers and uses this information to decide on new region assignments while ensuring a minimal impact on the current cache allocation. A region is assigned to the region server where it has a better cache ratio as compared to the region server where it is currently hosted.


The CacheAwareLoadBalancer uses two cost elements for deciding the region allocation. These are described below:

. Cache Cost
+

The cache cost is calculated as the percentage of data for a region cached on the region server where it is either currently hosted or was previously hosted. A region may have multiple HFiles, each of different sizes. A HFile is considered to be fully prefetched when all the data blocks in this file are in the cache. The region server hosting this region calculates the ratio of number of HFiles cached in the bucket cache to the total number of HFiles in the region. This ratio will vary from 0 (region hosted on this server, but none of its HFiles are cached into the bucket cache) to 1 (region hosted on this server and all the HFiles for this region are cached into the bucket cache).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace prefetched by cached.

replace bucket cache by cache.

+
Every region server maintains this information for all the regions currently hosted there. In addition to that, this cache ratio is also maintained for the regions which were previously hosted on this region server giving historical information about the regions.

. Skewness Cost
+
The skewness cost is calculated as the number of regions hosted on each region server in the cluster. The skewness cost varies from 0 (regions are equally distributed across the region servers) to 1 (regions are not equally distributed across the region servers).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can skip the explanation about skewness. In the next line, just mention this balancer implementation will combine the cache cost with skewness to decide on the assignment plan.


The balancer considers these two costs and calculates the resulting cost of maintaining the balance in the cluster. The balancer will attempt to rebalance the cluster under following conditions:

. There is an idle server in the cluster. This can happen when an existing server is restarted or a new server is added to the cluster.

. When the cost of maintaining the balance in the cluster is greater than the minimum threshold defined by the configuration _hbase.master.balancer.stochastic.minCostNeedBalance_.

The cluster can be made to use the CacheAwareLoadBalancer by setting the following configuration properties:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion:

Enable the CacheAwareLoadBalancer by setting the following configuration properties in the master configuration:


[source,xml]
----
<property>
<name>hbase.master.loadbalancer.class</name>
<value>org.apache.hadoop.hbase.master.balancer.CacheAwareLoadBalancer</value>
</property>
<property>
<name>hbase.bucketcache.persistent.path</name>
<value>/path/to/bucketcache_persistent_file</value>
</property>
----


[[regionserver_splitting_implementation]]
=== RegionServer Splitting Implementation

Expand Down