測試叢集:9個region server(16 core + 24GB記憶體)。Hbase client機器(8 core + 32GB記憶體)
資料量:日誌資料,1122MB,儲存在hdfs中。 hbase rowkey為9個位元組,第一個位元組是hash值,後八個位元組對應long型數值;value約200b。
寫效能關鍵影響因素
1. rowkey分布式是否均衡,最好先瞭解rowkey的特徵,預設splitkeys,將rowkey範圍均衡地分散到各個region server上;這樣,可以減輕單點負載,提升橫向拓展能力,並減少split和compact這樣的重操作。
2. autoflush設定為false
3. 如果記憶體足夠,可以適當增大WriteBufferSize,預設2MB,我調到32MB效果不錯。
4. 適當配置寫入線程。
5. WAL設定為false,可以明顯提升速度,但是不建議這麼做,這樣可能資料丟失無法恢複。
測試結果:
1.將多列屬性值壓縮至一個列中,可以大大提升hbase寫的效率;每多一列,寫入的效能都會明顯下降。
2.一個列族N個屬性列與N個列族單個屬性列,寫入效能很接近。
3. 單個region平均可以達到2w lines/s
測試結果
一個列族 + 一個列(包含所有的屬性值)
Total time costs : 66s
Average byte speed : 17MB/s
Average line speed : 170485lines/s
Total transferred records : 11252045
Total discarded records : 0
一個列族 + 一個列(包含所有的屬性值)+一個空值列
Total time costs : 99s
Average byte speed : 11MB/s
Average line speed : 113657lines/s
Total transferred records : 11252045
Total discarded records : 0
一個列族 + 一個列(包含所有的屬性值)+三個空值列
Total time costs : 166s
Average byte speed : 6MB/s
Average line speed : 67783lines/s
Total transferred records : 11252045
Total discarded records : 0
四個列族 + 每個列族一個列(包含所有的屬性值)
Total time costs : 159s
Average byte speed : 7MB/s
Average line speed : 70767lines/s
Total transferred records : 11252045
Total discarded records : 0
一個列族 + 四個列(每個列包含所有的屬性值)
Total time costs : 160s
Average byte speed : 7MB/s
Average line speed : 70325lines/s
Total transferred records : 11252045
Total discarded records : 0