hbase中regionserver的flush过程

1、regionServer的全局memstore的大小,超过该大小会触发flush到磁盘的操作,默认是堆大小的40%,

  而且regionserver级别的flush会阻塞客户端读写

 <property>  
        <name>hbase.regionserver.global.memstore.size</name>  
        <value></value>  
        <description>Maximum size of all memstores in a region server before  
            new  
            updates are blocked and flushes are forced. Defaults to 40% of heap (0.4).  
            Updates are blocked and flushes are forced until size of all  
            memstores  
            in a region server hits  
            hbase.regionserver.global.memstore.size.lower.limit.  
            The default value in this configuration has been intentionally left  
            emtpy in order to  
            honor the old hbase.regionserver.global.memstore.upperLimit property if  
            present.  
        </description>  
    </property> 
2、可以理解为一个安全的设置,有时候集群的“写负载”非常高,写入量一直超过flush的量,这时,我们就希望memstore不要超过一定的安全设置。   
        在这种情况下,写操作就要被阻塞一直到memstore恢复到一个“可管理”的大小, 这个大小就是默认值是堆大小 * 0.4 * 0.95,也就是当regionserver级别的flush操作发送后,会阻塞客户端写,一直阻塞到整个regionserver级别的memstore的大小为 堆大小 * 0.4 *0.95为止 

<property>  
        <name>hbase.regionserver.global.memstore.size.lower.limit</name>  
        <value></value>  
        <description>Maximum size of all memstores in a region server before  
            flushes are forced.  
            Defaults to 95% of hbase.regionserver.global.memstore.size (0.95).  
            A 100% value for this value causes the minimum possible flushing to  
            occur when updates are  
            blocked due to memstore limiting.  
            The default value in this configuration has been intentionally left  
            emtpy in order to  
            honor the old hbase.regionserver.global.memstore.lowerLimit property if  
            present.  
        </description>  
     </property>  

3、单个region里memstore的缓存大小,超过那么整个HRegion就会flush,默认128M

<property>  
        <name>hbase.hregion.memstore.flush.size</name>  
        <value>134217728</value>  
        <description>  
            Memstore will be flushed to disk if size of the memstore  
            exceeds this number of bytes. Value is checked by a thread that runs  
            every hbase.server.thread.wakefrequency.  
        </description>  
    </property>  

4、内存中的文件在自动刷新之前能够存活的最长时间,默认是1h

 <property>  
        <name>hbase.regionserver.optionalcacheflushinterval</name>  
        <value>3600000</value>  
        <description>  
            Maximum amount of time an edit lives in memory before being automatically  
            flushed.  
            Default 1 hour. Set it to 0 to disable automatic flushing.  
        </description>  
    </property> 

5、当一个 region 中的 memstore 的大小大于这个值的时候,我们又触发 了 close.会先运行“pre-flush”操作,清理这个需要关闭的memstore,然后 将这个 region 下线。当一个 region 下线了,我们无法再进行任何写操作。 如果一个 memstore 很大的时候,flush操作会消耗很多时间。"pre-flush" 操作意味着在 region 下线之前,会先把 memstore 清空。这样在最终执行 close 操作的时候,flush 操作会很快。 

<property>  
        <name>hbase.hregion.preclose.flush.size</name>  
        <value>5242880</value>  
        <description>  
            If the memstores in a region are this size or larger when we go  
            to close, run a "pre-flush" to clear out memstores before we put up  
            the region closed flag and take the region offline. On close,  
            a flush is run under the close flag to empty memory. During  
            this time the region is offline and we are not taking on any writes.  
            If the memstore content is large, this flush could take a long time to  
            complete. The preflush is meant to clean out the bulk of the memstore  
            before putting up the close flag and taking the region offline so the  
            flush that runs under the close flag has little to do.  
        </description>  
    </property>  

HBase集群的性能调优中,合理配置`zookeeper.session.timeout`和`hbase.regionserver.handler.count`是关键步骤之一。首先,`zookeeper.session.timeout`需要根据应用的具体场景和故障恢复能力来调整。对于需要快速故障检测和切换的应用,建议使用较短的超时时间,但同时需要保证网络稳定性和服务器的快速恢复能力,以避免因网络波动或短暂的宕机导致的不必要的RegionServer宕机检测和集群重新平衡。通常,可以根据实际应用的网络状况和服务器的重启时间进行多次调整测试,以找到最佳的超时设置。 参考资源链接:[HBase性能调优:优化Zookeeper会话超时与请求处理器计数](https://wenku.youkuaiyun.com/doc/2k5bu6svnt?spm=1055.2569.3001.10343) 其次,`hbase.regionserver.handler.count`则涉及到请求处理能力和内存管理。对于高吞吐量的场景,增加处理器计数可以提高并发处理能力,但同时也要注意内存的使用情况,防止因为过多的IO线程导致内存资源耗尽,从而触发频繁的flush操作和GC(垃圾回收),影响整体的TPS性能。在实际应用中,可以通过模拟高负载的压测环境,使用RPC级别的日志监控每个请求的内存消耗和GC情况,从而找到内存消耗和线程数之间的平衡点。 在调整这两个参数时,建议采取逐步逼近的方法,结合实际的监控数据,不断微调以达到最佳性能。此外,还应考虑集群的Region分布均衡性,以及读写锁的合理使用,确保系统的稳定性和扩展性。《HBase性能调优:优化Zookeeper会话超时与请求处理器计数》一书中提供了更多关于这两个参数调整的实践案例和深入分析,对于希望深入了解和实践HBase性能调优的读者来说,是一份不可或缺的学习资料。 参考资源链接:[HBase性能调优:优化Zookeeper会话超时与请求处理器计数](https://wenku.youkuaiyun.com/doc/2k5bu6svnt?spm=1055.2569.3001.10343)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值