我有一个 5 个工作节点集群,每个节点有 6 GB 内存(Spark 执行程序内存设置为 4608 GB)。
我的内存不足,Spark 告诉我,我的一个执行程序正在尝试使用超过 5.0 GB 的内存。如果每个执行器获得 5 GB 内存,那么整个集群之间的内存总量应该为 25 GB。
ExecutorLostFailure (executor 4 exited caused by one of the running tasks)
Reason: Container killed by YARN for exceeding memory limits. 5.0 GB of 5.0
GB physical memory used. Consider boosting spark.yarn.executor.memoryOverhead.
在我的 Spark 应用程序开始时,当我在“存储”选项卡中查看我的一个 RDD 时(此时它是缓存中唯一的 rdd),我看到:
RDD Name Storage Level Cached Partitions Fraction Cached Size in Memory Size on Disk
myRDD Memory Serialized 1x Replicated 20 100% 3.2 GB 0.0 B
Host On Heap Memory Usage Off Heap Memory Usage Disk Usage
Node 1 643.5 MB (1931.3 MB Remaining) 0.0 B (0.0 B Remaining) 0.0 B
Master 0.0 B (366.3 MB Remaining) 0.0 B (0.0 B Remaining) 0.0 B
Node 2 654.8 MB (1920.0 MB Remaining) 0.0 B (0.0 B Remaining) 0.0 B
Node 3 644.2 MB (1930.6 MB Remaining) 0.0 B (0.0 B Remaining) 0.0 B
Node 4 656.2 MB (1918.6 MB Remaining) 0.0 B (0.0 B Remaining) 0.0 B
Node 5 652.4 MB (1922.4 MB Remaining) 0.0 B (0.0 B Remaining) 0.0 B
这似乎表明每个节点只有大约 2.5 GB 的可用内存。在我的 Spark 应用程序出现内存不足错误之前,存储选项卡也从未接近显示 25 GB 的缓存 RDD。
如何知道为缓存 RDD 分配了多少内存?
最佳答案
提交作业时,您可以指定参数spark.memory.storageFraction
。默认值为 0.5。
因此,如果您为执行程序分配 5G 内存,则将保留 2.5G 用于缓存,剩余的 2.5G 将用于执行。
spark.memory.storageFraction
Amount of storage memory immune to eviction, expressed as a fraction of the size of the region set aside by spark.memory.fraction. The higher this is, the less working memory may be available to execution and tasks may spill to disk more often. Leaving this at the default value is recommended. For more detail, see this description.
关于hadoop - 为缓存 RDD 分配了多少内存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47603692/