Spark RDD - 分区是否总是在 RAM 中? [英] Spark RDD - is partition(s) always in RAM?

查看:41
本文介绍了Spark RDD - 分区是否总是在 RAM 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们都知道 Spark 在内存中进行计算.我只是对以下内容感到好奇.

We all know Spark does the computation in memory. I am just curious on followings.

  1. 如果我从 HDFS 在我的 pySpark shell 中创建 10 个 RDD,是否意味着所有这 10 个 RDD 的数据都将驻留在 Spark Workers 内存中?

  1. If I create 10 RDD in my pySpark shell from HDFS, does it mean all these 10 RDDs data will reside on Spark Workers Memory?

如果我不删除RDD,它会永远在内存中吗?

If I do not delete RDD, will it be in memory forever?

如果我的数据集(文件)大小超过可用 RAM 大小,数据将存储在哪里?

If my dataset(file) size exceeds available RAM size, where will data to stored?

推荐答案

如果我从 HDFS 在我的 pySpark shell 中创建 10 个 RDD,是否意味着所有这 10 个 RDD数据将驻留在 Spark 内存中?

是的,所有 10 个 RDD 数据都将分布在 Spark Worker 机器 RAM 中.但并不是所有的机器都必须每个RDD都有一个分区.当然,只有在对数据执行任何操作时,RDD 才会在内存中保存数据,因为它是惰性评估的.

Yes, All 10 RDDs data will spread in spark worker machines RAM. but not necessary to all machines must have a partition of each RDD. off course RDD will have data in memory only if any action performed on it as it's lazily evaluated.

如果我不删除RDD,它会永远在内存中吗?

Spark 自动取消持久化 RDD 或数据帧(如果不再使用它们).为了知道 RDD 或 Dataframe 是否被缓存,您可以进入 Spark UI --> 存储表并查看内存详细信息.您可以使用 df.unpersist()sqlContext.uncacheTable("sparktable") 从内存中删除 df 或表.阅读更多链接

Spark Automatically unpersist the RDD or Dataframe if they are no longer used. In order to know if an RDD or Dataframe is cached, you can get into the Spark UI -- > Storage table and see the Memory details. You can use df.unpersist() or sqlContext.uncacheTable("sparktable") to remove the df or tables from memory. link to read more

如果我的数据集大小超过可用的 RAM 大小,数据将到哪里存储?

如果 RDD 不适合内存,某些分区将不会被缓存,并且每次需要时都会重新计算.阅读更多链接

If the RDD does not fit in memory, some partitions will not be cached and will be recomputed on the fly each time, when they're needed. link to read more

如果我们说 RDD 已经在 RAM 中,这意味着它在内存中,那么需要 persist() 吗?--根据评论

回答你的问题,当在 RDD 上触发任何操作时,如果该操作找不到内存,它可以删除未缓存/非持久化的 RDD.

To answer your question, when any action triggered on RDD and if that action could not find memory, it can remove uncached/unpersisted RDDs.

一般来说,我们持久化需要大量计算或/和改组的 RDD(默认情况下,spark 持久化改组后的 RDD 以避免昂贵的网络 I/O),所以当在持久化 RDD 上执行任何操作时,它只会执行该操作,而不是根据沿袭图从头开始重新计算,在此处检查 RDD 持久性级别.

In general, we persist RDD which need a lot of computation or/and shuffling (by default spark persist shuffled RDDs to avoid costly network I/O), so that when any action performed on persisted RDD, simply it will perform that action only rather than computing it again from start as per lineage graph, check RDD persistence levels here.

这篇关于Spark RDD - 分区是否总是在 RAM 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆