Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache spark Spark Streaming动态分配执行器AllocationManager_Apache Spark_Spark Streaming - Fatal编程技术网

Apache spark Spark Streaming动态分配执行器AllocationManager

Apache spark Spark Streaming动态分配执行器AllocationManager,apache-spark,spark-streaming,Apache Spark,Spark Streaming,我们有一个spark 2.1流媒体应用程序,带有mapWithState,启用spark.streaming.DynamicLocation.enabled=true。管道如下: var rdd_out=ssc.textFileStream() .map(convertToEvent(33;)) .combineByKey(..,新的HashPartitioner(分区)) .mapWithState(stateSpec) .map(s=>会话分析) .foreachRDD(rdd=>rdd.t

我们有一个spark 2.1流媒体应用程序,带有
mapWithState
,启用
spark.streaming.DynamicLocation.enabled=true
。管道如下:

var rdd_out=ssc.textFileStream()
.map(convertToEvent(33;))
.combineByKey(..,新的HashPartitioner(分区))
.mapWithState(stateSpec)
.map(s=>会话分析)
.foreachRDD(rdd=>rdd.toDF()…保存(输出));
流媒体应用程序以2个执行器开始,一段时间后,随着负载按预期增加,它会创建新的执行器。问题在于,这些执行者没有分担负载

分区的数量大到足以溢出到新的执行器,并且密钥是均匀分布的,我设置了40多个分区,但在
mapWithState
存储上只能看到8个分区(2个执行器x 4个内核)。我希望在分配新的执行器时,这8个分区会被拆分并分配给新的执行器,但这永远不会发生

请告知


谢谢,

显然答案一直盯着我的脸:)。根据下面的文档,RDD应该继承上游分区

   * Otherwise, we use a default HashPartitioner. For the number of partitions, if
   * spark.default.parallelism is set, then we'll use the value from SparkContext
   * defaultParallelism, otherwise we'll use the max number of upstream partitions.
但是,mapWithState中的状态没有上游RDD。因此,除非您直接在状态中指定分区,否则将设置为默认并行性,如下例所示

val stateSpec = StateSpec.function(crediting.formSession _)
        .timeout(timeout)
        .numPartitions(partitions)  // <----------

var rdd_out = ssc.textFileStream()
    .map(convertToEvent(_))
    .combineByKey(...., new HashPartitioner(partitions))
    .mapWithState(stateSpec)
    .map(s => sessionAnalysis(s))
    .foreachRDD( rdd => rdd.toDF().....save(output));
val stateSpec=stateSpec.function(crediting.formSession)
.超时(超时)
.numPartitions(分区)//会话分析)
.foreachRDD(rdd=>rdd.toDF()…保存(输出));

仍然需要弄清楚如何使分区的数量动态,就像动态分配一样,这应该在运行时改变。

我很确定有状态转换不能以这种方式工作,
spark.streaming.dynamicAllocation.enabled
根本帮不了你。“State”是这里的引用,因为它是分区的,所以它将作为一个“模板”。@zero323,您能否详细介绍一下“模板”,因为状态和其他任何状态一样保存在一组RDD上。我本以为它可以重新平衡。ThxBut要“重新平衡”,您必须对其进行重新调整,以便它需要一个重新分区状态的选项。“仍然需要弄清楚如何使分区数量动态,就像动态分配一样,这应该在运行时改变。”这也适用于流式应用程序中的任何其他rdd。