我是 Spark 的新手。我在多个地方读到在 RDD 上使用 cache() 会导致它存储在内存中,但到目前为止我还没有找到关于“如何确定最大数据大小”的明确指导方针或经验法则塞进内存?如果我调用“缓存”的数据量超过内存,会发生什么?它会导致我的工作失败,还是会在完成后对集群性能产生显着影响?
谢谢!
最佳答案
正如 the official documentation 中明确说明的那样与 MEMORY_ONLY
持久性(相当于 cache
):
If the RDD does not fit in memory, some partitions will not be cached and will be recomputed on the fly each time they're needed.
即使数据适合内存,如果有新数据进入,它也可能被驱逐。实际上,缓存更像是一种提示而不是契约。您不能依赖缓存发生,但如果它成功,您也不必依赖。
备注 :
请记住默认
StorageLevel
为 Dataset
是 MEMORY_AND_DISK
,这将:If the RDD does not fit in memory, store the partitions that don't fit on disk, and read them from there when they're needed.
另见 :
关于apache-spark - 如果 Spark 中的 cache() 无法将数据放入内存中会发生什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35708833/