apache-spark - Apache Spark - 访问 RDD 上的内部数据?

标签 apache-spark rdd checkpointing

我开始做 amp-camp 5 exercises .我尝试了以下两种情况:

场景#1

val pagecounts = sc.textFile("data/pagecounts")
pagecounts.checkpoint
pagecounts.count

场景#2

val pagecounts = sc.textFile("data/pagecounts")
pagecounts.count

两者在 Spark shell 应用程序 UI 中显示的总时间不同 场景。
场景 #1 用了 0.5 秒,而场景 #2 只用了 0.2 s

在场景 #1 中,checkpoint 命令什么都不做,它既不是 转变也不是行动。它说一旦 RDD 实现 操作后,继续并保存到磁盘。我在这里错过了什么吗?

问题:

  1. 我知道方案 #1 需要更多时间,因为 RDD 是 检查点(写入磁盘)。有没有办法让我知道所花的时间 对于检查点,从总时间开始?
    Spark shell 应用程序 UI 显示以下内容 - 调度程序延迟、任务 反序列化时间、GC时间、Result序列化时间、获取结果 时间。但是,不显示检查点的故障。

  2. 有没有办法访问上述指标,例如调度程序延迟,GC 时间 并以编程方式保存它们?我想记录上面的一些指标 在 RDD 上调用的每个操作。

  3. 如何以编程方式访问以下信息:

    • RDD 的大小,当在检查点上持久化到磁盘时?
    • 当前有多少百分比的 RDD 在内存中?
    • 计算一个 RDD 所花费的总时间?

如果您需要更多信息,请告诉我。

最佳答案

Spark REST API几乎可以满足您的所有需求。

一些例子;

How much percentage of an RDD is in memory currently?

GET/api/v1/applications/[app-id]/storage/rdd/0

将回复:

{
  "id" : 0,
  "name" : "ParallelCollectionRDD",
  "numPartitions" : 2,
  "numCachedPartitions" : 2,
  "storageLevel" : "Memory Deserialized 1x Replicated",
  "memoryUsed" : 28000032,
  "diskUsed" : 0,
  "dataDistribution" : [ {
    "address" : "localhost:54984",
    "memoryUsed" : 28000032,
    "memoryRemaining" : 527755733,
    "diskUsed" : 0
  } ],
  "partitions" : [ {
    "blockName" : "rdd_0_0",
    "storageLevel" : "Memory Deserialized 1x Replicated",
    "memoryUsed" : 14000016,
    "diskUsed" : 0,
    "executors" : [ "localhost:54984" ]
  }, {
    "blockName" : "rdd_0_1",
    "storageLevel" : "Memory Deserialized 1x Replicated",
    "memoryUsed" : 14000016,
    "diskUsed" : 0,
    "executors" : [ "localhost:54984" ]
  } ]
}

Overall time taken for computing an RDD?

计算 RDD 也称为作业、阶段或尝试。 GET/applications/[app-id]/stages/[stage-id]/[stage-attempt-id]/taskSummary

将回复:

{
  "quantiles" : [ 0.05, 0.25, 0.5, 0.75, 0.95 ],
  "executorDeserializeTime" : [ 2.0, 2.0, 2.0, 2.0, 2.0 ],
  "executorRunTime" : [ 3.0, 3.0, 4.0, 4.0, 4.0 ],
  "resultSize" : [ 1457.0, 1457.0, 1457.0, 1457.0, 1457.0 ],
  "jvmGcTime" : [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
  "resultSerializationTime" : [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
  "memoryBytesSpilled" : [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
  "diskBytesSpilled" : [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
  "shuffleReadMetrics" : {
    "readBytes" : [ 340.0, 340.0, 342.0, 342.0, 342.0 ],
    "readRecords" : [ 10.0, 10.0, 10.0, 10.0, 10.0 ],
    "remoteBlocksFetched" : [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
    "localBlocksFetched" : [ 2.0, 2.0, 2.0, 2.0, 2.0 ],
    "fetchWaitTime" : [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
    "remoteBytesRead" : [ 0.0, 0.0, 0.0, 0.0, 0.0 ],
    "totalBlocksFetched" : [ 2.0, 2.0, 2.0, 2.0, 2.0 ]
  }
}

你的问题太笼统了,我就不一一回复了。我相信 Spark 必须反射(reflect)的一切都反射(reflect)在 REST API 中。

关于apache-spark - Apache Spark - 访问 RDD 上的内部数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32861504/

相关文章:

scala - 未找到 SparkContext 类错误

apache-spark - 如何并行运行多个Spark作业?

apache-spark - Apache Spark : Unexpected filter results

apache-spark-sql - 如何在pyspark中设置setCheckpoint

apache-spark - 如何测试流窗口聚合?

python - 在 pyspark Dataframe 中找到 10,000 列的均值和校正

scala - Apache Spark 溢出到磁盘

scala - Spark : How to use mapPartition and create/close connection per partition

apache-spark - MapWithState 给出 java.lang.ClassCastException : org. apache.spark.util.SerializableConfiguration cannot be cast while recovering from checkpoint