HBase写入优化

优化前主要问题

  • 吞吐量– 数据量达到1.59M 后 迅速下降

 

  • 虽然创建了13个预分区,但是由于单个请求的量依然很大,所以请求还是分摊在3-4台机器上,分布式集群的能力没有完全发挥出来

 

优化后

  • 请求达到了64000/s
  • 每秒请求平均在>1.5M

  • 请求数 下降

  • MemberStore 占用提升 -4.1G

 

写入流程

 

优化

  • 利用分布式集群优势,确保请求负载均衡

结合具体数据的RowKey特征创建预分区

create 'Monitor_','d', SPLITS => ['HSF.Response.Receive|', 'HSF.Response.Sent|', 'Teld.SQL|','HSF.Request.Time|']

写入时默认在RowKey 之前增加一位,A-Z

数据读取时,去掉RowKey的第一位

 

  • 集群的RegionServer 在某些情况下会阻止数据的写入,尽量减少这种情况的发生
  1. 根据数据灵活调整WAL的持久化等级
    1. WAL默认的等级为同步,会阻塞数据的写入。

    2. 一般的持久化等级采用异步即可,对于写入量很大的监控数据不在写入wal

      alter 'Monitor', METHOD => 'table_att', DURABILITY => 'SKIP_WAL'

 

  • 提高RegionServer 处理外部请求的能力
  1. 调整 hbase.hstore.blockingStoreFiles 的大小,默认值为7, 生产环境调整到100000
    1. Memstore 在flush前,会进行storeFile的文件数量校验,如果大于设定值,则阻止这个Memsore的数据写入,等待其他线程将storeFile进行合并,为了建设合并的概率,建设写入的阻塞,提高该参数值
  2. 由于region split 期间,大量的数据不能读写,防止对大的region进行合并造成数据读写的时间较长,调整对应的参数,如果region 大小大于20G,则region 不在进行split
    hbase.hstore.compaction.max.size 调整为20G 默认为 Long.MAX_VALUE(9223372036854775807)
  3. region server在写入时会检查每个region对应的memstore的总大小是否超过了memstore默认大小的2倍(hbase.hregion.memstore.block.multiplier决定),如果超过了则锁住memstore不让新写请求进来并触发flush,避免产生OOM
    hbase.hregion.memstore.block.multiplier 生产为8 默认为2

4     增加hlog 同步到磁盘的线程个数

hbase.hlog.asyncer.number 调整大10 默认为5

5    写入数据量比较大的情况下,避免region中过多的待刷新的memstore,增加memstore的刷新线程个数

    hbase.hstore.flusher.count 调整到20 默认为1

 

  • 减少客户端和服务端ipc,请求的次数,可以批量写入的采用批量写入
  1. 针对目前每次写入的数据量变大,调整服务端处理请求的线程数量
    1. hbase.regionserver.handler.count 默认值为10 调整到400

 

  • 增加hbaserest 端并行执行的能力
  1. 增加hbrest 并行处理的线程个数
    1. 'hbase.rest.threads.max 调整到400
  2. 采用hbase的批量写入
    1. hbase.client.write.buffer 修改为5M

 

配置:

 

默认

修改

描述

zookeeper.session.timeout

180000ms

600000    

zk超时时间

hbase.regionserver.thread.compaction.throttle

 

53687091200

默认为2 * hbase.hstore.compaction.max * hbase.hregion.memstore.flush.size

全部取默认值等于2*10*128MB = 2.5GB

hbase.zookeeper.property.tickTime

6000ms

 

心跳间隔

hbase.regionserver.optionalcacheflushinterval

3600000ms

 

memstore刷新间隔, 防止产生大量小文件

hbase.client.scanner.timeout.period

60000ms

1200000ms

单次scan超时时间

hbase.rpc.timeout

60000ms

1200000ms

rpc请求超时时间

hbase.regionserver.lease.period

60000ms

1200000ms

客户端租用HRegion server 期限

phoenix.query.timeoutMs  

 

180000ms

 

hbase.regionserver.handler.count

10

400

regionserver能够处理的请求线程数

hbase.master.namespace.init.timeout

 

1200000

 

phoenix.coprocessor.maxServerCacheTimeToLiveMs

30000

1800000

服务器端缓存的最大生存时间

phoenix.coprocessor.maxMetaDataCacheTimeToLiveMs

180000

1800000

服务器端元数据缓存的过期时间

hbase.hstore.blockingStoreFiles

10

1000

storefile数量达到多少时block住update操作

index.writer.threads.max

10

200

 

index.builder.threads.max

10

200

 

org.apache.phoenix.regionserver.index.handler.count

30

200

 

hbase.regionserver.hlog.blocksize

32m

536870912

hlog大小

hbase.regionserver.maxlogs

32

 

hlog数目

hbase.wal.provider

 

multiwal

 

hbase.wal.regiongrouping.numgroups

 

16

 

hbase.regionserver.maxlogs

 

4

 

hbase.regionserver.thread.compaction.small

1

1

小合并线程数,影响cpu使用及io

hbase.regionserver.thread.compaction.large

1

1

大合并线程数

hbase.hstore.compaction.max.size

 

4294967296

超过此大小不参与合并

hbase.hstore.flusher.count

2

8

flush线程数

hbase.hlog.asyncer.number

5

10

syncer线程数

hbase.hstore.blockingWaitTime

90000

30000

阻止写等待时间

hbase.server.thread.wakefrequency

10000

2000

检查memostore大小间隔

hbase.rest.threads.max

100

400

rest线程

hbase.regionserver.hlog.splitlog.writer.threads

3

10

hregion启动时日志分割

hbase.client.write.buffer

2m

5242880

客户端写入缓存

hbase.regionserver.optionallogflushinterval

1000ms

10000ms

wal刷到hdfs时间间隔

hbase.ipc.server.callqueue.handler.factor

0.1

0.2

 

hbase.ipc.server.callqueue.read.ratio

 

0.4

 

hbase.ipc.server.callqueue.scan.ratio

 

0.6

 

  • 3
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值