3
我看到了主節點上的Java堆緩慢用完的問題。下面是我創建的一個簡單的例子,它重複了200次。與主內存用完,低於約1小時,出現以下錯誤的設置:Spark驅動程序堆內存問題
16/12/15 17:55:46 INFO YarnSchedulerBackend$YarnDriverEndpoint: Launching task 97578 on executor id: 9 hostname: ip-xxx-xxx-xx-xx
#
# java.lang.OutOfMemoryError: Java heap space
# -XX:OnOutOfMemoryError="kill -9 %p"
# Executing /bin/sh -c "kill -9 20160"...
驗證碼:
import org.apache.spark.sql.functions._
import org.apache.spark._
object MemTest {
case class X(colval: Long, colname: Long, ID: Long)
def main(args: Array[String]) {
val conf = new SparkConf().setAppName("MemTest")
val spark = new SparkContext(conf)
val sc = org.apache.spark.sql.SQLContext.getOrCreate(spark)
import sc.implicits._;
for(a <- 1 to 200)
{
var df = spark.parallelize((1 to 5000000).map(x => X(x.toLong, x.toLong % 10, x.toLong/10))).toDF()
df = df.groupBy("ID").pivot("colname").agg(max("colval"))
df.count
}
spark.stop()
}
}
我在AWS EMR-5.1.0使用M4運行。 xlarge(4個節點+ 1個主站)。這裏是我的火花設置
{
"Classification": "spark-defaults",
"Properties": {
"spark.dynamicAllocation.enabled": "false",
"spark.executor.instances": "16",
"spark.executor.memory": "2560m",
"spark.driver.memory": "768m",
"spark.executor.cores": "1"
}
},
{
"Classification": "spark",
"Properties": {
"maximizeResourceAllocation": "false"
}
},
我使用
name := "Simple Project"
version := "1.0"
scalaVersion := "2.11.7"
libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-core" % "2.0.2" % "provided",
"org.apache.spark" %% "spark-sql" % "2.0.2")
與SBT編譯,然後使用
spark-submit --class MemTest target/scala-2.11/simple-project_2.11-1.0.jar
望着內存jmap -histo
我看到java.lang.Long
和scala.Tuple2
繼續增長運行它。
這是星火2.0.1,因爲這是EMR-5.1.0。我會嘗試emr-5.2.0。 –
與Spark 2.0.2沒有什麼區別 –