您好,登錄后才能下訂單哦!
這篇文章主要介紹HBase 0.94中的Split策略有什么用,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
HBase 0.94之前版本中,split使用的是ConstantSizeRegionSplitPolicy。當(dāng)region中文件大小超過配置中所指定大小時(shí),會(huì)進(jìn)行切分。
而在0.94版本之后,默認(rèn)split策略修改為了IncreasingToUpperBoundRegionSplitPolicy。該策略使用了另一種方法來計(jì)算是否應(yīng)當(dāng)切割,導(dǎo)致原先的參數(shù)失效。
該方法中的分配策略,是根據(jù)table中region的個(gè)數(shù)平方,乘以memstore的大小。得出應(yīng)當(dāng)切分的大小。
假設(shè)memstore size配置為128M,則在memstore第一次刷入HFile數(shù)據(jù)時(shí),進(jìn)行第一次split,1 * 1 * 128M = 128M。
當(dāng)region數(shù)達(dá)到2個(gè)時(shí),2 * 2 * 128M = 512M。
當(dāng)region數(shù)達(dá)到3個(gè)時(shí),3 * 3 * 128M = 1152M。
依此類推。
當(dāng)region個(gè)數(shù)到達(dá)30個(gè)時(shí),30 * 30 * 128 = 107648M = 105.1G。即在此時(shí),region的切分大小已經(jīng)超過了我們原先在ConstantSizeRegionSplitPolicy策略中設(shè)置的100G大小。
對(duì)這種策略進(jìn)行簡單的分析,可以看到,在數(shù)據(jù)寫入初期,這種策略可以快速的對(duì)現(xiàn)有region進(jìn)行split,使得在一開始就可以將熱點(diǎn)region切分到多個(gè)server上。同時(shí)由于region size較小,也可以避免split操作對(duì)寫入的阻塞。
而在后期,當(dāng)region數(shù)量逐漸增多,單個(gè)region size逐漸增大時(shí),split頻率會(huì)急速減少,避免在region過大時(shí)頻繁split的情況。
這種策略一方面在數(shù)據(jù)量增大的情況下減少了region的切分次數(shù),達(dá)到了我們期望的盡量減少split的需求,避免對(duì)寫入造成影響。同時(shí)在初期的快速切分,在基本不影響寫入的同時(shí),也減少了我們原先需要手動(dòng)操作split的問題??梢哉J(rèn)為,這種策略是符合我們需求的。當(dāng)然,還需要進(jìn)一步的測試來進(jìn)行驗(yàn)證。
源碼如下:
/** * @return Region max size or <code>count of regions squared * flushsize, which ever is * smaller; guard against there being zero regions on this server. */ long getSizeToCheck(final int tableRegionsCount) { return tableRegionsCount == 0? getDesiredMaxFileSize(): Math.min(getDesiredMaxFileSize(), this.flushSize * (tableRegionsCount * tableRegionsCount)); } @Override protected boolean shouldSplit() { if (region.shouldForceSplit()) return true; boolean foundABigStore = false; // Get count of regions that have the same common table as this.region int tableRegionsCount = getCountOfCommonTableRegions(); // Get size to check long sizeToCheck = getSizeToCheck(tableRegionsCount); for (Store store : region.getStores().values()) { // If any of the stores is unable to split (eg they contain reference files) // then don't split if ((!store.canSplit())) { return false; } // Mark if any store is big enough long size = store.getSize(); if (size > sizeToCheck) { LOG.debug("ShouldSplit because " + store.getColumnFamilyName() + " size=" + size + ", sizeToCheck=" + sizeToCheck + ", regionsWithCommonTable=" + tableRegionsCount); foundABigStore = true; break; } } return foundABigStore; }
以上是“HBase 0.94中的Split策略有什么用”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。