大数据基础三:spark参数调优
spak运行原理&参数调优一、spark运行原理参考:Spark资源参数调优参数_TURING.DT-CSDN博客_spark 资源参数Hive on Spark调优_窗外的屋檐-CSDN博客_spark.executor.instances二、参数调优1、必调参数num-executors/spark.executor.instancesexecutor-memory/spark.exe
spak运行原理&参数调优
一、spark运行原理
参考:
Spark资源参数调优参数_TURING.DT-CSDN博客_spark 资源参数
Hive on Spark调优_窗外的屋檐-CSDN博客_spark.executor.instances
二、参数调优
1、必调参数
num-executors/spark.executor.instances
executor-memory/spark.executor.memory
executor-cores/spark.executor.cores
.set("spark.sql.hive.mergeFiles", "true") // 合并小文件
2、锦上添花
1、driver-memory:使用collect算子将RDD的数据全部拉取到Driver上进行处理,那么必须确保Driver的内存足够大,否则会出现OOM内存溢出的问题
2、spark.storage.memoryFraction:RDD持久化数据在Executor内存中能占的比例,默认是0.6。也就是说,默认Executor 60%的内存,可以用来保存持久化的RDD数据。
1)有较多的RDD持久化操作,该参数的值可以适当提高一些,保证持久化的数据能够容纳在内存中。避免内存不够缓存所有的数据,导致数据只能写入磁盘中,降低了性能。
2)但是如果Spark作业中的shuffle类操作比较多,而持久化操作比较少,那么这个参数的值适当降低一些比较合适。
3、spark.default.parallelism:num-executors * executor-cores的2~3倍较为合适;
该参数用于设置每个stage的默认task数量。
5、spark.driver.maxResultSize
collect操作,shuffle操作的时候要调大此参数
6、实际初始化的executor 数量
涉及到的参数:
--conf spark.dynamicAllocation.initialExecutors=150 \
--conf spark.dynamicAllocation.maxExecutors=1000 \
--conf spark.executor.instances=500 \
如果设置了“--num-executors”(或spark.executor.instances,最终的初始executor数量为:max(minExecutors, initialExecutor, num-executors/4)
更多推荐
所有评论(0)