Presto性能調(diào)優(yōu)小結(jié)Presto性能調(diào)優(yōu)的五大技巧
1 Presto性能調(diào)優(yōu)

1.1 概述
1.1.1 Presto架構(gòu)
圖1-1 Presto架構(gòu)
Presto是一個(gè)分布式的查詢引擎,本身并不存儲(chǔ)數(shù)據(jù),但是可以接入多種數(shù)據(jù)源,并且支持跨數(shù)據(jù)源的級(jí)聯(lián)查詢。
Presto的架構(gòu)分為:
Coodinator:解析SQL語(yǔ)句,生成執(zhí)行計(jì)劃,分發(fā)執(zhí)行任務(wù)給Worker節(jié)點(diǎn)執(zhí)行。
Discovery Server:Worker節(jié)點(diǎn)啟動(dòng)后向Discovery Server服務(wù)注冊(cè),Coordinator從Discovery Server獲得可以正常工作的Worker節(jié)點(diǎn)。
Worker:負(fù)責(zé)執(zhí)行實(shí)際查詢?nèi)蝿?wù),訪問(wèn)底層存儲(chǔ)系統(tǒng)。
存儲(chǔ):Presto的數(shù)據(jù)可以存儲(chǔ)在HDFS/OBS,推薦熱數(shù)據(jù)存儲(chǔ)在HDFS,冷數(shù)據(jù)存儲(chǔ)在OBS。
1.2 內(nèi)存調(diào)優(yōu)
1.2.1 內(nèi)存管理原理
Presto有三種內(nèi)存池,分別為GENERAL_POOL、RESERVED_POOL、SYSTEM_POOL。
GENERAL_POOL:用于普通查詢的physical operators。GENERAL_POOL值為 總內(nèi)存(Xmx值)- 預(yù)留的(max-memory-per-node)- 系統(tǒng)的(0.4 * Xmx)。
SYSTEM_POOL:系統(tǒng)預(yù)留內(nèi)存,用于讀寫buffer,worker初始化以及執(zhí)行任務(wù)必要的內(nèi)存。大小由config.properties里的resources.reserved-system-memory指定。默認(rèn)值為JVM?max?memory?*?0.4。
RESERVED_POOL:大部分時(shí)間里是不參與計(jì)算的,只有當(dāng)同時(shí)滿足如下情形下,才會(huì)被使用,然后從所有查詢里獲取占用內(nèi)存最大的那個(gè)查詢,然后將該查詢放到 RESERVED_POOL 里執(zhí)行,同時(shí)注意RESERVED_POOL只能用于一個(gè)Query。大小由config.properties里的query.max-memory-per-node指定,默認(rèn)值為:JVM?max?memory?*?0.1。
GENERAL_POOL有節(jié)點(diǎn)出現(xiàn)阻塞節(jié)點(diǎn)(block node)情況,即該node內(nèi)存不足。
RESERVED_POOL沒有被使用
l? query.max-memory:表示單個(gè)查詢?cè)诜植荚谒邢嚓P(guān)節(jié)點(diǎn)上能用的內(nèi)存之和的最大值。
l? query.max-memory-per-node:表示單個(gè)查詢?cè)趩蝹€(gè)節(jié)點(diǎn)上用戶內(nèi)存能用的最大值。
l? query.max-total-memory-per-node:表示單個(gè)查詢?cè)趩蝹€(gè)節(jié)點(diǎn)上用戶內(nèi)存能用的最大值和系統(tǒng)內(nèi)存量。其中系統(tǒng)內(nèi)存是讀取器、寫入器和網(wǎng)絡(luò)緩沖區(qū)等在執(zhí)行期間使用的內(nèi)存。
l? memory.heap-headroom-per-node:這個(gè)內(nèi)存主要是第三方庫(kù)的內(nèi)存分配,無(wú)法被統(tǒng)計(jì)跟蹤,默認(rèn)值是-Xmx * 0.3。
注意點(diǎn):
query.max-memory-per-node小于query.max-total-memory-per-node。
query.max-total-memory-per-node 與memory.heap-headroom-per-node 之和必須小于 jvm max memory 也就是jvm.config 中配置的-Xmx。
圖1-2 Presto內(nèi)存池
圖1-3 Presto內(nèi)存配置
1.2.2 內(nèi)存調(diào)優(yōu)參數(shù)
操作場(chǎng)景
Presto由于是完全基于內(nèi)存的計(jì)算,經(jīng)常出現(xiàn)OOM,需要調(diào)整內(nèi)存。
修改參數(shù)
參數(shù)名
默認(rèn)值
描述
優(yōu)化建議
修改位置
query.max-memory-per-node
jvm * 0.1
表示單個(gè)查詢?cè)趩蝹€(gè)節(jié)點(diǎn)上用戶內(nèi)存能用的最大值
jvm * 0.25
config.properties
query.max-total-memory-per-node
> query.max-memory-per-node
表示單個(gè)查詢?cè)趩蝹€(gè)節(jié)點(diǎn)上用戶內(nèi)存能用的最大值和系統(tǒng)內(nèi)存量。其中系統(tǒng)內(nèi)存是讀取器、寫入器和網(wǎng)絡(luò)緩沖區(qū)等在執(zhí)行期間使用的內(nèi)存
jvm * 0.4
config.properties
memory.heap-headroom-per-node
jvm * 0.3
這個(gè)內(nèi)存主要是第三方庫(kù)的內(nèi)存分配,無(wú)法被統(tǒng)計(jì)跟蹤
jvm * 0.2
config.properties
query.max-memory
< query.max-memory-per-node * worker
表示單個(gè)查詢?cè)诜植荚谒邢嚓P(guān)節(jié)點(diǎn)上能用的內(nèi)存之和的最大值
query.max-memory-per-node * worker * 0.8
config.properties
query.low-memory-killer.policy
none
當(dāng)查詢發(fā)生OOM時(shí)的處理策略。配置total-reservation的作用是kill掉所有查詢里最費(fèi)內(nèi)存的查詢;而total-reservation-on-blocked-nodes殺死在內(nèi)存不足(阻塞)的節(jié)點(diǎn)上使用最多內(nèi)存的查詢
total-reservation-on-blocked-nodes
jvm.config
experimental.reserved-pool-enabled
true
是否啟用Reserved Pool
并發(fā)較多時(shí), RESERVED_POOL可能被閑置,可以關(guān)閉RESERVED_POOL
config.properties
1.2.3 常見OOM報(bào)錯(cuò)
1.3 并行度
操作場(chǎng)景
調(diào)整線程數(shù)增大task的并發(fā)以提高效率。
修改參數(shù)
參數(shù)名
默認(rèn)值
描述
優(yōu)化建議
修改位置
task.concurrency
16
執(zhí)行join,aggregation等操作的并發(fā)度
串行調(diào)高并行調(diào)低
config.properties
task.max-worker-threads
cpu core * 2
worker處理split的線程數(shù)
如果工作器CPU利用率低并且所有線程都在使用中,則增加此數(shù)目可以提高吞吐量,但是會(huì)導(dǎo)致堆空間使用率增加。將該值設(shè)置得太高可能會(huì)由于上下文切換而導(dǎo)致性能下降。線程數(shù)可通過(guò)com.facebook.presto.execution.executor:name = ? TaskExecutor.RunningSplits JXM對(duì)象的RunningSplits屬性獲得
config.properties
node-scheduler.max-splits-per-node
100
每個(gè)worker上處理的split數(shù)
單個(gè)split處理時(shí)間短時(shí)調(diào)大
config.properties
1.4 元數(shù)據(jù)緩存
操作場(chǎng)景
Presto支持Hive connector,元數(shù)據(jù)存儲(chǔ)在Hive metastore中,調(diào)整元數(shù)據(jù)緩存的相關(guān)參數(shù)可以提高訪問(wèn)元數(shù)據(jù)的效率。
修改參數(shù)
參數(shù)名
默認(rèn)值
描述
優(yōu)化建議
修改位置
hive.metastore-cache-ttl
Time to live Hive metadata cache
1440s
catalog/hive.properties
hive.metastore-refresh-interval
How often to refresh the Hive metastore cache
1h
catalog/hive.properties
hive.metastore-cache-maximum-size
Hive metastore cache maximum size
10000
catalog/hive.properties
hive.metastore-refresh-max-threads
Maximum number of threads to refresh Hive metastore cache.
100
catalog/hive.properties
1.5 Hash優(yōu)化
操作場(chǎng)景
針對(duì)Hash場(chǎng)景的優(yōu)化。
修改參數(shù)
參數(shù)名
默認(rèn)值
描述
優(yōu)化建議
修改位置
query.initial-hash-partitions
8, If the value is larger than the number of machines available during ? query scheduling, Presto will use all available machines
當(dāng)分區(qū)系統(tǒng)設(shè)置為FIXED時(shí),此值用于確定可以有多少個(gè)節(jié)點(diǎn)共享同一查詢
Value lower then number of presto nodes may lower the utilization of ? cluster in low traffic environment. Setting the number to to high value will ? cause assigning multiple partitions of same query to one node or ignoring the ? setting - in some configurations the value is internally capped at number of ? available worker nodes
config.properties
optimizer.optimize-hash-generation
Compute hash codes for distribution, joins, and aggregations early in ? query plan which may allow to drop some of computation later in query ? processing with the cost of increased preprocessing. In most cases it should decrease ? overall query processing time
true
config.properties
1.6 優(yōu)化OBS相關(guān)參數(shù)
操作場(chǎng)景
Presto支持on OBS,讀寫OBS過(guò)程中可以調(diào)整OBS客戶端參數(shù)來(lái)提交讀寫效率。
修改參數(shù)
參數(shù)名
默認(rèn)值
描述
優(yōu)化建議
修改位置
fs.obs.readahead.range
讀數(shù)據(jù)時(shí),發(fā)起預(yù)讀建立range讀的請(qǐng)求大小
4194304
core-site.xml
fs.obs.write.buffer.size
OBS FS中的讀寫緩沖區(qū)大小
262144
core-site.xml
fs.obs.read.buffer.size
OBS FS中的讀寫緩沖區(qū)大小
262144
core-site.xml
本博客地址:https://bbs.huaweicloud.com/blogs/173486
大數(shù)據(jù)
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請(qǐng)聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請(qǐng)聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。