spark submit 參數及其調優


https://blog.csdn.net/guohecang/article/details/52088117 Spark配置參數詳解

一.yarn模式下一個示例:

./bin/spark-submit \
  --master yarn-cluster \
  --num-executors 100 \
  --executor-memory 6G \
  --executor-cores 4 \
  --driver-memory 1G \
  --conf spark.default.parallelism=1000 \
  --conf spark.storage.memoryFraction=0.5 \
  --conf spark.shuffle.memoryFraction=0.3 \

二.參數說明:
    1.在公司使用最多的 spark on yarn模式
    2.num-executors:
        ①用於設置Spark作業要用多少個Executor進程來執行.
        ②Driver在向YARN集群管理器申請資源時會按照這個設置來在集群的各個工作節點上啟動相應數量的Executor進程,過大浪費,過小導致任務運行速度慢或者無法啟動
    3.executor-cores:
        ①用於設置Executor進程的CPU core數量.這個參數決定了每個Executor進程並行執行task線程的能力.因為每個CPU core同一時間只能執行一個task線程,因此每個Executor進程的CPU core數量越多,越能夠快速地執行完分配給自己的所有task線程
        ②
    4.driver-memory:
        ①用於設置Driver進程的內存
        ②如果需要使用collect算子將RDD的數據全部拉取到Driver上進行處理,那么必須確保Driver的內存足夠大,否則會出現OOM內存溢出的問題
    5.spark.default.parallelism:
        ①用於設置stage的默認task數量
        ②建議設置該參數為num-executors * executor-cores的2~3倍
    6.spark.storage.memoryFraction:
        ①用於設置RDD持久化數據在Executor內存中能占的比例,默認是0.6
        ②如果Spark作業中,有較多的RDD持久化操作,值適當提高一些,保證持久化的數據能夠容納在內存中。避免內存不夠緩存所有的數據,導致數據只能寫入磁盤中,降低了性能
    7.spark.shuffle.memoryFraction:
        ①用於設置shuffle過程中一個task拉取到上個stage的task的輸出后,進行聚合操作時能夠使用的Executor內存的比例,默認是0.2
        ②shuffle操作在進行聚合時,如果發現使用的內存超出了這個值(默認20%)的限制,那么多余的數據就會溢寫到磁盤文件中去,此時就會極大地降低性能
        
三.示例:

source /test1/test2/test.sh
source $localroot/scripts/$config
appPid=0
start_process(){
spark-submit --master yarn-cluster \
--name apple.banana\
--principal $principal \
--keytab $keytab \
--num-executors 4 \
--executor-cores 2 \
--executor-memory 8G \
--driver-memory 8G \
--conf spark.locality.wait=10 \
--conf spark.kryoserializer.buffer.max=500MB \
--conf spark.serializer="org.apache.spark.serializer.KryoSerializer" \
--conf spark.streaming.backpressure.enabled=true \
--conf spark.task.maxFailures=8 \
--conf spark.streaming.kafka.maxRatePerPartition=1000 \
--conf spark.driver.maxResultSize=5g \
--conf spark.driver.extraClassPath=$localroot/config \
--conf spark.executor.userClassPathFirst=true \
--conf spark.yarn.executor.memoryOverhead=4g \
--conf spark.executor.extraJavaOptions="test" \
--conf spark.yarn.cluster.driver.extraJavaOptions="test" \
--files $localroot/config/test.properties,\
$localroot/config/test1.txt,\
$localroot/config/test2.txt,\
$localroot/config/test3.txt \
--class com.peanut.test \
--jars $SPARK_HOME/jars/streamingClient010/kafka_2.10-0.10.0.0.jar,\
$SPARK_HOME/jars/streamingClient010/kafka-clients-0.10.0.0.jar,\
$SPARK_HOME/jars/streamingClient010/spark-streaming-kafka-0-10_2.11-2.1.0.jar,\
$localroot/lib/test1.jar,\
$localroot/lib/test2.jar,\
$localroot/lib/test3.jar \
$jarpath \
$args1 \
$args2 \
$args3 &

appPid=$!
}
start_process

echo "pid is"
echo $appPid

exit

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM