docker 最大container数量调研

1、本地笔记本测试docker同时启动500个容器

首先测试docker daemon支持的最大docker容器数量,查询文档发现,最大容器数量大概是1023个左右,在自己笔记本测试,启动500个容器,需要四分钟,i7、8G,说明docker启动250个容器应该没有任务问题。具体过程在:
https://blog.csdn.net/warrior_0319/article/details/79730191

2、docker系统资源限制

docker创建和使用了很多的系统资源去启动容器,许多系统限制,存在灰色地带取决于你的docker容器配置、你容器中运行的程序、你的硬件设备、docker版本等,下面是总结的一些系统限制:

  1. 链接到虚拟网络适配器docker0网桥的设备限制:(最多1023/网桥)
  2. 挂载联合文件系统(AUFS)和shm文件系统:(最大挂载数量1048576)
  3. 在镜像image上创建的层数layer数量:(最多127layer每个镜像)
  4. fork出来一个docker-containerd-shim的管理进程:(每个容器平均3M左右,系统最大进程数sysctl kernel.pid_max)
  5. docker daemon守候进程管理容器的内部数据:(~400k 每个容器)
  6. 创建内核的cgroup和namespace
  7. 打开文件描述符:(启动中的容器16个左右) ulimit -n and sysctl fs.file-max
  8. 端口映射,-p将会在宿主机上为每一个映射的端口启动一个外部进程:(平均每个端口占用~4.5MB每个端口)
  9. –net=none 和 –net=host将会移除网络消耗。

Container 服务
总的资源消耗取决于你容器内运行的程序,而不是docker本身,如果你在虚拟机中运行应用程序node,ruby,python,java,内存的消耗将是主要问题。
1000个进程会消耗大大量的IO 链接。1000个进程同时运行也会引起大量的上下文交换,

1023 Docker busybox images

nc -l -p 80 -e echo

uses up about 1GB of kernel memory and 3.5GB of system memory.

1023 普通进程

nc -l -p 80 -e echo

host processes running on a host uses about 75MB of kernel memory and 125MB of system memory

Starting 1023 containers serially took ~8 minutes.
Killing 1023 containers serially took ~6 minutes

参考地址:https://stackoverflow.com/questions/21799382/is-there-a-maximum-number-of-containers-running-on-a-docker-host
参考地址:https://groups.google.com/forum/#!topic/docker-user/k5hqpNg8gwQ

参考地址:https://gowalker.org/github.com/portworx/docker_v1.9.0/errors

docker ulimit 设置

–default-ulimit参数可以设置所有容器的 ulimit,他跟docker run命令的–ulimit 参数相同,

// ErrorCodeJoinRunning is generated when we try to network to ourselves.
ErrorCodeJoinRunning = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: “JOINRUNNING”,
Message: “cannot join network of a non running container: %s”,
Description: “An attempt to join the network of a container, but that container isn’t running”,
HTTPStatusCode: http.StatusInternalServerError,
}

OK, after a longer research I’ve got a solution to fix the problem.
The solution is described here: https://coderwall.com/p/myodcq

Finally I just edited the file “/etc/init/docker.conf” on my Ubuntu 12.04 Docker Host:
Only add “limit nofile 65536 65536”, and the problem is fixed!

Here is the complete file:

description “Docker daemon”

start on filesystem and started lxc-net
stop on runlevel [!2345]

set max file descriptors to 65536 (soft/hard)

limit nofile 65536 65536

respawn

script
DOCKER=/usr/bin/ UPSTARTJOBDOCKEROPTS=if[f/etc/default/ U P S T A R T J O B D O C K E R O P T S = i f [ − f / e t c / d e f a u l t / UPSTART_JOB ]; then
. /etc/default/ UPSTARTJOBfi U P S T A R T J O B f i “ DOCKER" -d $DOCKER_OPTS
end script

Right now, I’m running a ramp up on a VirtualBox machine (2 vCPUs, 4GByte memory) on my MBP, more than 500 containers already started so far.


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值