更新时间:2022-09-30 GMT+08:00

配置事件队列的大小

配置场景

Spark中见到的UI、EventLog、动态资源调度等功能都是通过事件传递实现的。事件有SparkListenerJobStart、SparkListenerJobEnd等,记录了每个重要的过程。

每个事件在发生后都会保存到一个队列中,Driver在创建SparkContext对象时,会启动一个线程循环的从该队列中依次拿出一个事件,然后发送给各个Listener,每个Listener感知到事件后就会做各自的处理。

因此当队列存放的速度大于获取的速度时,就会导致队列溢出,从而丢失了溢出的事件,影响了UI、EventLog、动态资源调度等功能。所以为了更灵活的使用,在这边添加一个配置项,用户可以根据Driver的内存大小设置合适的值。

配置描述

参数入口:

在执行应用之前,在Spark服务配置中修改。在Manager系统中,选择集群 > 待操作集群的名称 > 服务 > Spark2x > 配置,单击“全部配置”。在搜索框中输入参数名称。

表1 参数说明

参数

描述

默认值

spark.scheduler.listenerbus.eventqueue.capacity

事件队列的大小,可以根据Driver的内存做适当的配置。

1000000

当Driver日志中出现如下的日志时,表示队列溢出了。

  1. 普通应用:
    Dropping SparkListenerEvent because no remaining room in event queue. 
    This likely means one of the SparkListeners is too slow and cannot keep
    up with the rate at which tasks are being started by the scheduler.
  2. Spark Streaming应用:
    Dropping StreamingListenerEvent because no remaining room in event queue.
    This likely means one of the StreamingListeners is too slow and cannot keep
    up with the rate at which events are being started by the scheduler.