gpt4 book ai didi

docker - 为什么 Openshift 报告的容器内存使用量比本地运行的相同 Docker 容器大得多?

转载 作者:行者123 更新时间:2023-12-02 03:00:44 25 4
gpt4 key购买 nike

我有一个 Docker 容器,它在本地运行时报告此资源使用情况:

docker run -i --rm -p 8080:8080 my-application

如您所见,容器使用了 10.6MiB:

docker ps -q | xargs  docker stats --no-stream             
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
b73afe5ee771 mystifying_neumann 0.00% 10.6MiB / 7.777GiB 0.13% 11.7kB / 2.38kB 0B / 0B 21

现在我在 Openshift 中运行该容器,设置以下内存限制:

        resources:
limits:
memory: 64Mi
requests:
memory: 64Mi

当 Pod 启动时,我预计会使用大约 11MiB,总共 64MiB。然而容器正在使用 53MiB!!!为什么会出现这种差异?

enter image description here

最佳答案

我终于在这两个引用文献中找到了这种差异的原因:

https://github.com/openshift/origin-web-console/issues/1315

https://access.redhat.com/solutions/3639191

总结:Docker 将内存报告为 rss 和缓存等多个元素的相加:

https://docs.docker.com/config/containers/runmetrics/#metrics-from-cgroups-memory-cpu-block-io

cache The amount of memory used by the processes of this control group that can be associated precisely with a block on a block device. When you read from and write to files on disk, this amount increases. This is the case if you use “conventional” I/O (open, read, write syscalls) as well as mapped files (with mmap). It also accounts for the memory used by tmpfs mounts, though the reasons are unclear.

rss The amount of memory that doesn’t correspond to anything on disk: stacks, heaps, and anonymous memory maps.

Openshift 3.x 使用 Heapster 读取该信息,但无法区分两种类型的内存。

如果您检查 Openshift 内运行的容器的 docker 统计信息,您会发现预期(较低)的值。

关于docker - 为什么 Openshift 报告的容器内存使用量比本地运行的相同 Docker 容器大得多?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60901601/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com