spark-shell --master local-cluster[x,y,z] spark.default.parallelism =
x * y
mesos 细粒度模式
Mesos fine grained mode spark.default.parallelism = 8
其他模式(这里主要指yarn模式,当然standalone也是如此) Others: total number of cores on
all executor nodes or 2, whichever is larger spark.default.parallelism
= max(所有executor使用的core总数, 2)
经过上面的规则,就能确定了spark.default.parallelism的默认值(前提是配置文件spark-default.conf中没有显示的配置,如果配置了,则spark.default.parallelism = 配置的值)还有一个配置比较重要,spark.files.maxPartitionBytes = 128 M(默认)
The maximum number of bytes to pack into a single partition when reading files.代表着rdd的一个分区能存放数据的最大字节数,如果一个400m的文件,只分了两个区,则在action时会发生错误。当一个spark应用程序执行时,生成spark.context,同时会生成两个参数,由上面得到的spark.default.parallelism推导出这两个参数的值