为了账号安全,请及时绑定邮箱和手机立即绑定

HBase性能优化系列(一)

标签:
Hbase

针对IO进行性能优化(一)

如果服务器IO能力弱,进行限流控制

Compaction吞吐量限制

有效版本 1.1.0+ 2.0.0+
hbase-2.0.0版本开始默认有限制,hbase-1.x版本默认不限制

HBASE-8329  
相关参数:
hbase.regionserver.throughput.controller  
hbase.hstore.compaction.throughput.offpeak  
hbase.hstore.compaction.throughput.lower.bound  
hbase.hstore.compaction.throughput.higher.bound  
hbase.hstore.blockingStoreFiles

解释如下:
增加Compaction吞吐量限制机制。
默认值是org.apache.hadoop.hbase.regionserver.compactions.PressureAwareCompactionThroughputController  
将限制吞吐量如下:

  1. 在非高峰时段(off peak hours),使用固定的限制hbase.hstore.compaction.throughput.offpeak(默认值是Long.MAX_VALUE,这意味着没有限制)

  2. 在正常时段,限制在hbase.hstore.compaction.throughput.lower.bound(默认10Mb/s)和hbase.hstore.compaction.throughput.higher.bound(默认20Mb/s)之间,使用公式"lower + (higer - lower) * param"计算,param范围:[0,1 ],并基于该RegionServer上StoreFile数量进行计算。

  3. 如果一些Store有太多的StoreFile(StoreFile数量大于上限hbase.hstore.blockingStoreFiles),那么没有限制,无论是高峰或非高峰。

可以将hbase.regionserver.throughput.controller设置为org.apache.hadoop.hbase.regionserver.throttle.NoLimitThroughputController,禁用吞吐量控制。

而且已经实现了ConfigurationObserver观察者,这意味着可以更改上面的所有配置,不需要重新启动群集。

1.3.0版本的包路径 org.apache.hadoop.hbase.regionserver.throttle

部分代码实现

// NoLimitThroughputController不控制流量,代码实现无public class PressureAwareCompactionThroughputController 
    implements CompactionThroughputController {    
    // 控制Compact流量,如果速度太快通过Sleep控制
    @Override
    public long control(String compactionName, long size) throws InterruptedException {        // 正在运行的Compaction
        ActiveCompaction compaction = activeCompactions.get(compactionName);
        compaction.totalSize += size;        
        long deltaSize = compaction.totalSize - compaction.lastControlSize;}        
        long now = EnvironmentEdgeManager.currentTime();        double maxThroughputPerCompaction = this.maxThroughput / activeCompactions.size();        // Compaction最低时间
        long minTimeAllowed = (long) (deltaSize / maxThroughputPerCompaction * 1000); 
        long elapsedTime = now - compaction.lastControlTime;
        compaction.lastControlSize = compaction.totalSize;        if (elapsedTime >= minTimeAllowed) {            // 如果速度正常
            compaction.lastControlTime = EnvironmentEdgeManager.currentTime();            return 0;
        }        // 如果速度太快,Compact时间少于最低时间
        // 睡眠一段时间
        long sleepTime = minTimeAllowed - elapsedTime;
            
        Thread.sleep(sleepTime);
        compaction.numberOfSleeps++;
        compaction.totalSleepTime += sleepTime;
        compaction.lastControlTime = EnvironmentEdgeManager.currentTime();        return sleepTime;
    }
}

Flush限流

有效版本 1.3.0+ 2.0.0+
默认不开启

HBASE-14969  
相关参数:
hbase.regionserver.throughput.controller  
hbase.hstore.flush.throughput.upper.bound
hbase.hstore.flush.throughput.lower.bound  
hbase.hstore.flush.throughput.tune.period

解释如下:
增加Flush的流量控制。默认没有限制,org.apache.hadoop.hbase.regionserver.throttle.NoLimitThroughputController,可以修改为org.apache.hadoop.hbase.regionserver.throttle.PressureAwareFlushThroughputController,允许设置流量的界限。参考Compaction限流逻辑

代码实现参考Compaction限流实现



作者:Alex90
链接:https://www.jianshu.com/p/29b2ca0b4f11


点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消