首页 > 解决方案 > 在纱线上使用火花流进行动态分配,而不是缩小执行程序

问题描述

我在纱线集群上使用火花流(火花版本 2.2),并试图为我的应用程序启用动态核心分配。

执行器的数量根据需要增加,但是一旦分配了执行器,即使流量减少,它们也不会被缩减,即一旦分配的执行器不会被释放。我还在纱线上启用了外部洗牌服务,如此处所述: https ://spark.apache.org/docs/latest/running-on-yarn.html#configuring-the-external-shuffle-service

我在 spark-submit 命令中设置的配置是:

            --conf spark.dynamicAllocation.enabled=false \
            --conf spark.streaming.dynamicAllocation.enabled=true \
            --conf spark.streaming.dynamicAllocation.scalingInterval=30 \
            --conf spark.shuffle.service.enabled=true \
            --conf spark.streaming.dynamicAllocation.initialExecutors=15 \
            --conf spark.streaming.dynamicAllocation.minExecutors=10 \
            --conf spark.streaming.dynamicAllocation.maxExecutors=30 \
            --conf spark.streaming.dynamicAllocation.executorIdleTimeout=60s \
            --conf spark.streaming.dynamicAllocation.cachedExecutorIdleTimeout=60s \

如果我缺少任何特定的配置,有人可以帮忙吗?

谢谢

标签: apache-sparkspark-streamingapache-spark-2.2

解决方案


作为此 JIRA 的一部分添加的文档帮助了我:https ://issues.apache.org/jira/browse/SPARK-12133 。

需要注意的关键点是,当比率(批处理时间/批处理持续时间)小于 0.5(默认值)时,执行器的数量会减少,这实际上意味着执行器有一半时间处于空闲状态。可用于更改此默认值的配置是“spark.streaming.dynamicAllocation.scalingDownRatio”


推荐阅读