AWS ECS 中的 fs.file-max 和 ulimit nofile 是否受 EC2 的 fs.file-max 和 nofile 的限制?

Raj*_*hna 5 amazon-ec2 ulimit amazon-web-services amazon-ecs docker

我正在尝试在 ECS 上运行的 Nginx 上运行一些负载测试,并且我已ulimit通过文档中提到的任务定义将 设置为更高的值 (777001) 。

在容器内,容器内的ulimit -Hn命令和cat /proc/sys/fs/file-max运行将给出与输出相同的值 ()。

在运行容器(自动扩展集群中的 EC2 之一)的 EC2 上,ulimit -Hn指定为 1024,cat /proc/sys/fs/file-max指定为 777001。

当我运行负载时,too many open files当每秒请求数达到 500 左右时出现错误。(ECS 服务的 CPU 使用率和内存使用率似乎在 25% 左右)。

在对此进行一些挖掘时,我发现了这篇中等文章,其中引用了/etc/sysconfig/docker提供给 docker 守护程序的文件和启动选项。在我的情况下,cat /etc/sysconfig/docker输出如下。

# The max number of open files for the daemon itself, and all
# running containers.  The default value of 1048576 mirrors the value
# used by the systemd service unit.
DAEMON_MAXFILES=1048576

# Additional startup options for the Docker daemon, for example:
# OPTIONS="--ip-forward=true --iptables=true"
# By default we limit the number of open files per container
OPTIONS="--default-ulimit nofile=1024:4096"

# How many seconds the sysvinit script waits for the pidfile to appear
# when starting the daemon.
DAEMON_PIDFILE_TIMEOUT=10
OPTIONS="${OPTIONS} --storage-opt dm.basesize=20G"
Run Code Online (Sandbox Code Playgroud)

我想要任何帮助来理解以下内容。

  1. 即使通过 ECS 任务定义将 ulimit nofile 设置为更高的值,EC2 上的 ulimit nofile 值是否也会限制 ECS 上的 ulimit nofile?
  2. /etc/sysconfig/docker即使通过 ECS 任务定义将 ulimit nofile 设置为更高的值,文件中提供给 docker daemon 的 OPTIONS 参数是否会限制 ECS 上的 ulimit nofile?