Spark动态Executor分配场景下executorAllocationRatio参数作用问询
Spark动态分配与executorAllocationRatio的配置分析
根据Spark的规则,初始启动的Executor数量由以下公式计算:
max( spark.dynamicAllocation.initialExecutors, spark.dynamicAllocation.minExecutors, spark.executor.instances )
举个例子,在以下配置场景中:
spark.dynamicAllocation.enabled=true spark.dynamicAllocation.minExecutors=1 spark.executor.instances = 10 spark.dynamicAllocation.maxExecutors=10
Spark会以10个Executor启动(即max(1,10)=10),且因为spark.dynamicAllocation.maxExecutors设为10,后续无法根据负载进行扩缩容。
配置executorAllocationRatio=0.5的实际表现
当同时配置spark.dynamicAllocation.executorAllocationRatio=0.5时,Spark会以5个Executor启动,并可按需扩容至10个。
具体逻辑:
executorAllocationRatio的作用是对动态分配相关的Executor数量参数(初始值、最小值、最大值)按比例调整。初始Executor数量先通过原公式算出为10,再乘以0.5得到5,作为实际启动的Executor数。spark.dynamicAllocation.maxExecutors=10是最终的扩容上限,当负载提升时,Spark会根据任务需求逐步扩容,直到达到10个Executor的上限,不会被限制在5个固定数量。
内容的提问来源于stack exchange,提问作者Matthew
相关产品推荐
相关产品推荐

