代码之家  ›  专栏  ›  技术社区  ›  pushpavanthar

纱线中的调谐火花作业

  •  0
  • pushpavanthar  · 技术社区  · 7 年前

    因为java,我的spark工作失败了。lang.OutOfMemoryError:Java堆空间。 我试着玩配置参数,比如 executor-cores ,则, executor-memory ,则, num-executors ,则, driver-cores ,则, driver-memory ,则, spark.yarn.driver.memoryOverhead ,则, spark.yarn.executor.memoryOverhead 根据 Ramzy's answer .下面是我的配置集

    --master yarn-cluster --executor-cores 4 --executor-memory 10G --num-executors 30 --driver-cores 4 --driver-memory 16G --queue team_high --conf spark.eventLog.dir=hdfs:///spark-history --conf spark.eventLog.enabled=true --conf spark.yarn.historyServer.address=xxxxxxxxx:xxxx --conf spark.sql.tungsten.enabled=true --conf spark.ui.port=5051 --conf spark.sql.shuffle.partitions=30 --conf spark.yarn.driver.memoryOverhead=1024 --conf spark.yarn.executor.memoryOverhead=1400 --conf spark.dynamicAllocation.enabled=true --conf spark.shuffle.service.enabled=true --conf spark.sql.orc.filterPushdown=true --conf spark.scheduler.mode=FAIR --conf hive.exec.dynamic.partition=false --conf hive.exec.dynamic.partition.mode=nonstrict --conf mapreduce.fileoutputcommitter.algorithm.version=2 --conf orc.stripe.size=67108864 --conf hive.merge.orcfile.stripe.level=true --conf hive.merge.smallfiles.avgsize=2560000 --conf hive.merge.size.per.task=2560000 --conf spark.driver.extraJavaOptions='-XX:+UseCompressedOops -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps' --conf spark.executor.extraJavaOptions='-XX:+UseCompressedOops -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC'
    

    对于上述问题,它有时有效,但多数情况下失败。 调试时,我发现了以下GC日志。有人能帮我理解这些日志并帮我调整这项工作吗?

    #
    # java.lang.OutOfMemoryError: Java heap space
    # -XX:OnOutOfMemoryError="kill %p"
    #   Executing /bin/sh -c "kill 79911"...
    Heap
     PSYoungGen      total 2330112K, used 876951K [0x00000006eab00000, 0x00000007c0000000, 0x00000007c0000000)
      eden space 1165312K, 75% used [0x00000006eab00000,0x0000000720365f50,0x0000000731d00000)
      from space 1164800K, 0% used [0x0000000731d00000,0x0000000731d00000,0x0000000778e80000)
      to   space 1164800K, 0% used [0x0000000778e80000,0x0000000778e80000,0x00000007c0000000)
     ParOldGen       total 6990848K, used 6990706K [0x0000000540000000, 0x00000006eab00000, 0x00000006eab00000)
      object space 6990848K, 99% used [0x0000000540000000,0x00000006eaadc9c0,0x00000006eab00000)
     Metaspace       used 69711K, capacity 70498K, committed 72536K, reserved 1112064K
      class space    used 9950K, capacity 10182K, committed 10624K, reserved 1048576K
    End of LogType:stdout
    
    1 回复  |  直到 7 年前
        1
  •  6
  •   a9207    7 年前

    我在集群中运行spark时遇到过间歇性内存问题,我发现这种情况主要是由于以下原因:-

    1) Rdd分区可能太大而无法处理,您可以通过使用重新分区API增加分区数来减小分区大小。这将减少每个执行器将要处理的数据量。由于您为一个执行器提供了10g和4个内核,这意味着该执行器可以运行4个并发任务(分区),而这4个任务之间将共享10g内存,这恰恰意味着只需2.5g即可处理一个分区。

    val rddWithMorePartitions = rdd.repartition(rdd.getNumPartitions*2)
    

    2) 如果您的用例是计算密集型的,并且您没有进行任何缓存,那么您可以通过调整以下参数来减少为存储分配的内存。

    火花存储memoryFraction=0.6(默认)

    您可以将其更改为以下-

    spark.storage.memoryFraction=0.5
    

    3) 您应该考虑将执行器内存增加到25gb以上。

    --executor-memory 26G