Skip to content

HBASE-28513 The StochasticLoadBalancer should support discrete evaluations - #6543

Closed
rmdmattingly wants to merge 1 commit into
apache:masterfrom
HubSpot:HBASE-28513
Closed

HBASE-28513 The StochasticLoadBalancer should support discrete evaluations#6543
rmdmattingly wants to merge 1 commit into
apache:masterfrom
HubSpot:HBASE-28513

Conversation

@rmdmattingly

@rmdmattinglyrmdmattingly commented Dec 13, 2024

Copy link
Copy Markdown
Contributor

See my design doc here

To sum it up, the current load balancer isn't great for what it's supposed to do now, and it won't support all of the things that we'd like it to do in a perfect world.

Right now: primary replica balancing squashes all other considerations. The default weight for one of the several cost functions that factor into primary replica balancing is 100,000. Meanwhile the default read request cost is 5. The result is that the load balancer, OOTB, basically doesn't care about balancing actual load. To solve this, you can either set primary replica balancing costs to zero, which is fine if you don't use read replicas, or — if you do use read replicas — maybe you can produce a magic incantation of configurations that work just right, until your needs change.

In the future: we'd like a lot more out of the balancer. System table isolation, meta table isolation, colocation of regions based on start key prefix similarity (this is a very rough idea atm, and not touched in the scope of this PR). And to support all of these features with either cost functions or RS groups would be a real burden. I think what I'm proposing here will be a much, much easier path for HBase operators.

New features

This PR introduces some new features:

  1. Balancer conditional based replica distribution
  2. System table isolation (put backups, quotas, etc on their own RegionServer (all sys tables on 1))
  3. Meta table isolation (put meta on its own RegionServer)

These can be controlled via:

  • hbase.master.balancer.stochastic.conditionals.distributeReplicas: set this to true to enable conditional based replica distribution
  • hbase.master.balancer.stochastic.conditionals.isolateSystemTables: set this to true to enable system table isolation
  • hbase.master.balancer.stochastic.conditionals.isolateMetaTable: set this to true to enable meta table isolation
  • hbase.master.balancer.stochastic.additionalConditionals: much like cost functions, you can define your own RegionPlanConditional implementation and install them here

Testing

I wrote a lot of unit tests to validate the functionality here — both lightweight and some minicluster tests. Even in the most extreme cases (like, system table isolation + meta table isolation enabled on a 3 node cluster, or the number of read replicas == the number of servers) the balancer does what we'd expect.

Replica Distribution Improvements

Not only does this PR offer an alternative means of distributing replicas, but it's actually a massive improvement on the existing approach.

See the Replica Distribution testing section of my design doc. Cost functions never successfully balance 3 replicas across 3 servers OOTB — but balancer conditionals do so expeditiously.

To summarize the testing, we have replicated_table, a table with 3 region replicas. The 3 regions of a given replica share a color, and there are also 3 RegionServers in the cluster. We expect the balancer to evenly distribute one replica per server across the 3 RegionServers...

Cost functions don't work:
cf1
cf2

….omitting the meaningless snapshots between 4 and 27…

cf28

At this point, I just exited the test because it was clear that our existing balancer would never achieve true replica distribution.

But balancer conditionals do work:
bc1
bc2
bc3
bc4
bc5

New Features: Table Isolation Working as Designed

See below where we ran a new unit test, TestLargerClusterBalancerConditionals, and tracked the locations of regions for 3 tables across 18 RegionServers:

  1. 180 “product” table regions
  2. 1 meta table region
  3. 1 quotas table region

All regions began on a single RegionServer, and within 4 balancer iterations we had a well balanced cluster, and isolation of key system tables. It achieved this in about 2min on my local machine, where most of that time was spent bootstrapping the mini cluster.

output (2)

output (3)

output (5)

output (4)

cc @ndimiduk@charlesconnell@ksravista@aalhour

@rmdmattingly
rmdmattinglyforce-pushed the HBASE-28513 branch 5 times, most recently from e1283f4 to 517c43bCompareDecember 13, 2024 23:40
@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@rmdmattingly

rmdmattingly commented Dec 14, 2024

Copy link
Copy Markdown
ContributorAuthor

Still cleaning this up with the help of the build logs. Will mark as a draft for now. I believe the code is working quite well though, so please feel free to review the proposal and meat of the changes

I'm still deciding whether it's necessary to create a balancer candidate for the replica conditional.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@rmdmattingly

rmdmattingly commented Dec 15, 2024

Copy link
Copy Markdown
ContributorAuthor

This is working really well in my testing, and I'm not convinced that it's necessary to add a replica distribution candidate generator. This is because, typically, each region replica has so many acceptable destinations (n-r+1, where n is the number of servers and r is the number of replicas), and so many acceptable swap candidates (any region who does not represent the same data). This is different from, say, a table isolation conditional where we really want to drain many virtually all regions from a single RegionServer, and no swaps are appropriate

This is probably work for a separate PR, but I think it would be nice to support pluggable candidate generators to pair with any custom conditionals that users write

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@rmdmattingly
rmdmattinglyforce-pushed the HBASE-28513 branch 2 times, most recently from ae58410 to d1622d1CompareDecember 16, 2024 02:21
@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@rmdmattingly
rmdmattinglyforce-pushed the HBASE-28513 branch 2 times, most recently from 8ac0c7a to 2ca6c63CompareDecember 31, 2024 15:22
@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@rmdmattingly
rmdmattinglyforce-pushed the HBASE-28513 branch 3 times, most recently from e94ba85 to 1cd2c34CompareJanuary 4, 2025 02:29
@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@rmdmattingly

rmdmattingly commented Jan 4, 2025

Copy link
Copy Markdown
ContributorAuthor

Build looks good here, and all of the balancer tests reliably pass on my machine within about 30min. I've improved the runtime of several tests too, because we previously made a lot of quick assumptions about the appropriate balancer runtime being 30s here, 60s there, and those really add up when running the full test suite repeatedly.

I've also setup a large cluster test for conditional replica balancing, at an identical scale to the existing large cluster test for legacy replica balancing. It demonstrates a significant improvement in balancer latency when dealing with 1k servers, 20k regions, 3 replicas per region, and 100 tables:
Screenshot 2025-01-04 at 11 48 55 AM

Because this PR is huge, and there is a lot of iteration along the way, I'm tempted to close this and reopen a clean PR with a passing build. I'll do that either this weekend, or early next week.

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeLogfileComment
+0 🆗reexec0m 37sDocker mode activated.
_ Prechecks _
+1 💚dupname0m 0sNo case conflicting files found.
+0 🆗codespell0m 0scodespell was not available.
+0 🆗detsecrets0m 0sdetect-secrets was not available.
+1 💚@author0m 0sThe patch does not contain any @author tags.
+1 💚hbaseanti0m 0sPatch does not have any anti-patterns.
_ master Compile Tests _
+0 🆗mvndep0m 10sMaven dependency ordering for branch
+1 💚mvninstall4m 4smaster passed
+1 💚compile4m 19smaster passed
+1 💚checkstyle0m 57smaster passed
+1 💚spotbugs2m 16smaster passed
+1 💚spotless0m 56sbranch has no errors when running spotless:check.
_ Patch Compile Tests _
+0 🆗mvndep0m 11sMaven dependency ordering for patch
+1 💚mvninstall3m 52sthe patch passed
+1 💚compile4m 13sthe patch passed
+1 💚javac0m 29shbase-balancer generated 0 new + 66 unchanged - 4 fixed = 66 total (was 70)
+1 💚javac3m 44shbase-server in the patch passed.
+1 💚blanks0m 0sThe patch has no blanks issues.
+1 💚checkstyle0m 57sthe patch passed
+1 💚spotbugs2m 30sthe patch passed
+1 💚hadoopcheck13m 40sPatch does not cause any errors with Hadoop 3.3.6 3.4.0.
+1 💚spotless1m 14spatch has no errors when running spotless:check.
_ Other Tests _
+1 💚asflicense0m 35sThe patch does not generate ASF License warnings.
49m 17s
SubsystemReport/Notes
DockerClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6543/21/artifact/yetus-general-check/output/Dockerfile
GITHUB PR#6543
Optional Testsdupname asflicense javac spotbugs checkstyle codespell detsecrets compile hadoopcheck hbaseanti spotless
unameLinux 80abf62311b3 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev-support/hbase-personality.sh
git revisionmaster / a689f06
Default JavaEclipse Adoptium-17.0.11+9
Max. process+thread count84 (vs. ulimit of 30000)
modulesC: hbase-balancer hbase-server U: .
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6543/21/console
versionsgit=2.34.1 maven=3.9.8 spotbugs=4.7.3
Powered byApache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeLogfileComment
+0 🆗reexec0m 41sDocker mode activated.
-0 ⚠️yetus0m 3sUnprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --author-ignore-list --blanks-eol-ignore-file --blanks-tabs-ignore-file --quick-hadoopcheck
_ Prechecks _
_ master Compile Tests _
+0 🆗mvndep0m 13sMaven dependency ordering for branch
+1 💚mvninstall4m 7smaster passed
+1 💚compile1m 30smaster passed
+1 💚javadoc0m 45smaster passed
+1 💚shadedjars7m 1sbranch has no errors when building our shaded downstream artifacts.
_ Patch Compile Tests _
+0 🆗mvndep0m 12sMaven dependency ordering for patch
+1 💚mvninstall3m 56sthe patch passed
+1 💚compile1m 25sthe patch passed
+1 💚javac1m 25sthe patch passed
+1 💚javadoc0m 42sthe patch passed
+1 💚shadedjars6m 38spatch has no errors when building our shaded downstream artifacts.
_ Other Tests _
+1 💚unit14m 52shbase-balancer in the patch passed.
+1 💚unit185m 39shbase-server in the patch passed.
232m 50s
SubsystemReport/Notes
DockerClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6543/21/artifact/yetus-jdk17-hadoop3-check/output/Dockerfile
GITHUB PR#6543
Optional Testsjavac javadoc unit compile shadedjars
unameLinux 9816d81d30da 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev-support/hbase-personality.sh
git revisionmaster / a689f06
Default JavaEclipse Adoptium-17.0.11+9
Test Resultshttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6543/21/testReport/
Max. process+thread count5313 (vs. ulimit of 30000)
modulesC: hbase-balancer hbase-server U: .
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-6543/21/console
versionsgit=2.34.1 maven=3.9.8
Powered byApache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@rmdmattingly

Copy link
Copy Markdown
ContributorAuthor

Closing this in favor of a new, clean PR

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@rmdmattingly@Apache-HBase@charlesconnell