我正在尝试同时将 1000 多个客户端(发布者/订阅者)连接到 mqtt 代理。连接达到 343 个客户端后,套接字 fd 已达到 > 1024,并且客户端未收到来自 MQTT 代理的连接确认。有没有办法增加availabe open socket fd的?
系统:Ubuntu 16.04
配置:
猫 /etc/sysctl.conf
fs.file-max = 10000000
fs.nr_open = 10000000
net.ipv4.tcp_mem = 786432 1697152 1945728
net.ipv4.tcp_rmem = 4096 4096 16777216
net.ipv4.tcp_wmem = 4096 4096 16777216
net.ipv4.ip_local_port_range = 1024 65535
猫 /etc/security/limits.conf:
soft nofile 10000000
hard nofile 10000000
root soft nofile 10000000
root hard nofile 10000000
ulimit -a 结果
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 7101
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 10000000
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 7101
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
猫 /proc/2628/limits
Limit Soft Limit Hard Limit Units
Max cpu time unlimited unlimited seconds
Max file size unlimited unlimited bytes
Max data size unlimited unlimited bytes
Max stack size 8388608 unlimited bytes
Max core file size 0 unlimited bytes
Max resident set unlimited unlimited bytes
Max processes 7101 7101 processes
Max open files 10000000 10000000 files
Max locked memory 65536 65536 bytes
Max address space unlimited unlimited bytes
Max file locks unlimited unlimited locks
Max pending signals 7101 7101 signals
Max msgqueue size 819200 819200 bytes
Max nice priority 0 0
Max realtime priority 0 0
Max realtime timeout unlimited unlimited us