在哪种情况下,火花驱动程序可能会耗尽内存?

时间:2015-05-20 01:54:43

标签: apache-spark

我在YARN上执行32个执行程序和--driver-memory 2G选项。 我得到例外如下

ERROR actor.ActorSystemImpl: Uncaught fatal error from thread [sparkDriver-akka.actor.default-dispatcher-2] shutting down ActorSystem [sparkDriver]
java.lang.OutOfMemoryError: GC overhead limit exceeded

我想知道在哪种情况下驱动程序可能会耗尽内存。 由于我使用RDD执行所有操作(例如map,filter,reduce,groupBy等),因此驱动程序不需要太多内存。

顺便说一下,程序生成的任务太多,有200多个阶段,其中很多都有40000个任务。这会导致问题吗?

这是主要逻辑:

class A { def id:VertexID }
class B ...


val data:RDD[A] = ...
val start_v:RDD[VertexID] = ...
val edges:RDD[Edge[B]] = ...

  def spanning(inits:RDD[VertexId],iterations:Int):RDD[VertexId] = {
    val medge = edges.groupBy(_.srcId) persist(StorageLevel.MEMORY_AND_DISK)
    var nodes = inits
    for (
      i<- 1 to iterations
    ){
      val step1 = nodes map (x => x -> x) join( medge )
      val step2 = step1 flatMap ( x=> x._2._2 map (_.dstId))
      nodes = (step2 ++ nodes) 
    }
    nodes distinct()
  }

    val result = spanning( start_v,100 )
    val sample_data = data map (x => x.id -> x) join( result map (x=> x -> 1) ) map (_._2._1)

    println(sample_data.count())

2 个答案:

答案 0 :(得分:0)

我认为你需要review which methods are actions而不是,因为行动会回到司机身上:

  

另一方面,reduce是聚合所有的动作   RDD的元素使用一些函数并返回最终结果   到驱动程序

答案 1 :(得分:0)

如果使用RDD.collect(),驱动程序可能会占用大量内存,因为它会将执行程序中的所有数据收集到驱动程序的内存中,以便进一步处理,如输出到外部系统。如果是这种情况,您可以考虑像RDD.foreachPartition这样的替代方案,它将注册一个将在执行程序中执行的函数。这样,所有数据都不会流回到驱动程序中。