HBase高并发读写
image.png
rowkey+预分区的合理设计(减少split)
提高region的容量也可以减少split
hbase.hregion.max.filesize
使用批量写入BulkLoad
先将数据写hdfs,然后直接加载为Hbase的HFile文件避免region的split,compact,flush等过程
HBase写入速度过快
-
加快flush的速度
hbase.hstore.blockingWaitTime = 90000 ms hbase.hstore.flusher.count = 2 hbase.hstore.blockingStoreFiles = 10
-
加快compact的速度,增加执行compaction的线程数
hbase.regionserver.thread.compaction.small = 1 hbase.regionserver.thread.compaction.large = 1
-
限制请求队列的大小,让客户端请求超时
hbase.ipc.server.max.callqueue.size = 1024 * 1024 * 1024 # 1G
-
减少Rpc的连接数
Hbase的客户端会数据累积到设置的阈值才会提交,所以提高这个缓冲区的大小。前提是必须禁止AutoFlush
HTable htable = new HTable(config, tablename); htable.setWriteBufferSize(6 * 1024 * 1024); htable.setAutoFlush(false);
-
提高RPC Handler数
<property> <name>hbase.regionserver.handler.count</name> <value>100</value> </property>
-
配置边写边压
因为IO也是写入得一个瓶颈
HColumnDescriptor hcd = new HColumnDescriptor(familyName); hcd.setCompressionType(Algorithm.SNAPPY);