影響HBase insert效能的幾個因素

2021-07-02 23:51:38 字數 1487 閱讀 7432

在使用hbase put api的時候,有幾個會影響效能的因素。

1.put list size

hbase的put支援單條插入,也支援批量插入。

2. autoflush

autoflush指的是在每次呼叫hbase的put操作,是否提交到hbase server。 預設是true,每次會提交。如果此時是單條插入,就會有更多的io,從而降低效能

3.write buffer size

write buffer size在autoflush為false的時候起作用,預設是2mb,也就是當插入資料超過2mb,就會自動提交到server

4.wal

wal是write ahead log的縮寫,指的是hbase在插入操作前是否寫log。預設是開啟,關掉會提高效能,但是如果系統出現故障(負責插入的region server掛掉),資料可能會丟失。

下面是乙個簡單的測試:

table: 4個family 每行插入的資料4kb,每次提交1000行

wal=false,autoflush=false,buffer=25165824 insert complete,costs:0.4453ms/row

wal=false,autoflush=true,buffer=0 insert complete,costs:0.6ms/row

wal=true,autoflush=true,buffer=0 insert complete,costs:1.8797ms/row

可以看出在wal關閉,並且設定比較合適的buffer size,可以將效能提高到4到5倍.

測試**:

public class testinsert

private static void insert(boolean wal,boolean autoflush,long writebuffer)

throws ioexception

htable table = new htable(hbaseconfig, tablename);

table.setautoflush(autoflush);

if(writebuffer!=0)

listlp = new arraylist();

long all = system.currenttimemillis();

int count = 10000;

byte buffer = new byte[1024];

random r = new random();

for (int i = 1; i <= count; ++i)

}system.out.println("wal="+wal+",autoflush="+autoflush+",buffer="+writebuffer);

system.out.println("insert complete"+",costs:"+(system.currenttimemillis()-all)*1.0/count+"ms");}}

try catch 的效能影響

現象 大量try.catch.newtonsoft.json序列化速度明顯降低 9000ms 250ms 疑問 大量try.catch.影響效能?主要效能消耗在於跳轉到catch塊?準則 不要將try.catch.用於處理 邏輯跳轉,僅用於常規異常處理 不要濫用try.catch.總結 try.ca...

Entity Framework效能影響因素分析

1 物件管理機制 複雜 為更好的管理模型物件,ef提供了一套內部管理機制和跟蹤物件的狀態,儲存物件一致性,使用方便,但是效能有所降低。2 執行機制 高度封裝 在ef中,所有的查詢表示式都會經過語法分析 解析sql語句 然後呼叫底層的ado.net物件去執行,中間的這些環節導致效能有所降低。3 sql...

影響hashMap效能的因素

首 先算得key得hashcode值,然後跟陣列的長度 1做一次 與 運算 看上去很簡單,其實比較有玄機。比如陣列的長度是2的4次方,那麼hashcode就會和2的4次方 1做 與 運算。很多人都有這個疑問,為什麼hashmap的陣列初始化大小都是2的次方大小時,hashmap 的效率最高,我以2的...