同一主机上的 Docker 个容器是否共享相同的页面缓存?
Do Docker containers on the same host machine share the same page cache?
如果我在同一台主机上有两个 Docker 容器 运行 它们各自有自己的页面缓存还是使用主机的页面缓存?
Page cache由内核管理,被所有容器使用
查看更多
Docker makes it easy to spawn a lot of containers and get better density, but it also makes it easy to run too many services on one machine or to run services which require way too much RAM.
The official documentation lists devicemapper
(direct-lvm
) as a production ready storage driver, but it doesn't have very efficient memory usage. The official documentation doesn't state otherwise either. Multiple identical containers will increase memory usage for the page cache.
In order to make this better and get better performance, the following should help, in a similar way to how it helps outside of Docker and containers in general:
- make containers smaller for long running services & applications (e.g. smaller binaries, smaller images, optimize memory usage, etc)
- VERY IMPORTANT: use volumes and bind mounts, instead of storing data inside the container
- VERY IMPORTANT: make sure to run a system with a maintained kernel, up to date Docker and devicemapper libraries (e.g. fully updated CentOS 7 / RHEL 7 / Ubuntu 14.04 / Ubuntu 16.04)
当前行为(2020 年 1 月)默认情况下,同一主机上的容器共享相同的页面缓存。
当前 docker 文档说明:
OverlayFS 是一个类似于 AUFS 的现代联合文件系统,但速度更快且实现更简单。 Docker为OverlayFS提供了两种存储驱动:原来的overlay,和更新更稳定的overlay2。
Docker Engine - Community 和 Docker EE 17.06.02-ee5 及更高版本支持 overlay2 驱动程序,并且是推荐的存储驱动程序。
页面缓存。 OverlayFS 支持页面缓存共享。访问同一文件的多个容器共享该文件的单个页面缓存条目。这使得 overlay 和 overlay2 驱动程序的内存效率更高,并且是 PaaS
等高密度用例的不错选择
https://docs.docker.com/storage/storagedriver/overlayfs-driver/
如果我在同一台主机上有两个 Docker 容器 运行 它们各自有自己的页面缓存还是使用主机的页面缓存?
Page cache由内核管理,被所有容器使用
查看更多Docker makes it easy to spawn a lot of containers and get better density, but it also makes it easy to run too many services on one machine or to run services which require way too much RAM.
The official documentation lists
devicemapper
(direct-lvm
) as a production ready storage driver, but it doesn't have very efficient memory usage. The official documentation doesn't state otherwise either. Multiple identical containers will increase memory usage for the page cache.In order to make this better and get better performance, the following should help, in a similar way to how it helps outside of Docker and containers in general:
- make containers smaller for long running services & applications (e.g. smaller binaries, smaller images, optimize memory usage, etc)
- VERY IMPORTANT: use volumes and bind mounts, instead of storing data inside the container
- VERY IMPORTANT: make sure to run a system with a maintained kernel, up to date Docker and devicemapper libraries (e.g. fully updated CentOS 7 / RHEL 7 / Ubuntu 14.04 / Ubuntu 16.04)
当前行为(2020 年 1 月)默认情况下,同一主机上的容器共享相同的页面缓存。
当前 docker 文档说明:
OverlayFS 是一个类似于 AUFS 的现代联合文件系统,但速度更快且实现更简单。 Docker为OverlayFS提供了两种存储驱动:原来的overlay,和更新更稳定的overlay2。
Docker Engine - Community 和 Docker EE 17.06.02-ee5 及更高版本支持 overlay2 驱动程序,并且是推荐的存储驱动程序。
页面缓存。 OverlayFS 支持页面缓存共享。访问同一文件的多个容器共享该文件的单个页面缓存条目。这使得 overlay 和 overlay2 驱动程序的内存效率更高,并且是 PaaS
等高密度用例的不错选择https://docs.docker.com/storage/storagedriver/overlayfs-driver/