目录

Supervisord服务性能调优

目录

../../images/weixin_public.png

安装脚本:

1
2
yum install -y epel-release 
yum install -y supervisor

程序配置文件

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
[program:XXXXXXXX]
process_name=%(program_name)s
command = 执行命令行
directory = 执行目录
autostart = true
startsecs = 5
autorestart = true
startretries = 3
user = root
redirect_stderr = false
stdout_logfile_maxbytes = 128MB
stdout_logfile_backups = 5
stdout_logfile = 执行目录/logs/XXXXXXXX-deamaon.log
stderr_logfile_maxbytes = 128MB
stderr_logfile_backups = 5
stderr_logfile = 执行目录/logs/XXXXXXXXX-errdeamaon.log
priority=999

系统配置

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
vim /etc/security/limits.conf
* soft nofile 655350
* hard nofile 655350
soft nproc 655350
hard nproc 655350

/etc/systemd/system.conf
 
在这个文件里面加入
 
DefaultLimitNOFILE=100000
DefaultLimitNPROC=65535

修改supervisord 服务配置

1
2
3
4
最小文件描述符数量
minfds=65535   默认 1024
最小进程数
minprocs=65535 默认 200
1
2
3
4
5
6
查找 supervisord 服务

find / -name supervisord.service

打开supervisord服务配置
vim /usr/lib/systemd/system/supervisord.service

服务配置文件:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf
新增    LimitCORE=infinity
新增    LimitNOFILE=1000000
新增    LimitNPROC=1000000




cat > /usr/lib/systemd/system/supervisord.service << EOF
[Unit]
Description=Supervisor process control system for UNIX
Documentation=http://supervisord.org
After=network.target
 
[Service]
Type=forking
LimitNOFILE=infinity
ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf
ExecStop=/usr/bin/supervisorctl $OPTIONS shutdown
ExecReload=/usr/bin/supervisorctl $OPTIONS reload
KillMode=process
Restart=on-failure
RestartSec=42s
 
[Install]
WantedBy=multi-user.target
EOF

配置重启

1
2
3
重启服务
systemctl daemon-reload
systemctl restart supervisord

重载配置文件

1
2
3
4
supervisorctl update
supervisorctl reload
supervisorctl restart
supervisorctl status

查看Limit是否生效

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
systemctl show -p DefaultLimit

systemctl show -p DefaultLimitNPROC

systemctl show -p DefaultLimitNOFILE
systemctl show supervisord -p LimitNOFILE
cat /proc/进程编号/limits


查看服务状态
supervisorctl  status