@Override
  public void setConf(Configuration conf) {
    this.conf = conf;
    boolean cacheKeys = conf.getBoolean(CACHE_REPLICA_KEYS_KEY, CACHE_REPLICA_KEYS_DEFAULT);
    if (cacheKeys && replicaKeyCache == null) {
      int replicaKeyCacheSize =
        conf.getInt(REPLICA_KEY_CACHE_SIZE_KEY, REPLICA_KEY_CACHE_SIZE_DEFAULT);
      replicaKeyCache = CacheBuilder.newBuilder().maximumSize(replicaKeyCacheSize)
        .expireAfterAccess(Duration.ofMinutes(30)).build(new CacheLoader<RegionInfo, ReplicaKey>() {
          @Override
          public ReplicaKey load(RegionInfo regionInfo) {
            return new ReplicaKey(regionInfo);
          }
        });
    } else if (!cacheKeys) {
      replicaKeyCache = null;
    }
  }
If memory is available, then set this to a value greater than your region count to maximize
replica distribution performance.
hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/replicas/ReplicaKeyCache.java