free -h
root@ic:/etc/php/7.3/fpm/pool.d# free -h
total used free shared buff/cache available
Mem: 7.8Gi 988Mi 514Mi 39Mi 6.3Gi 6.7Gi
Swap: 2.0Gi 30Mi 2.0Gi
ps --no-headers -o "rss,cmd" -C php-fpm7.3 | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'
計算max_children數
(6.7*1024)/38=180
vi /etc/php/7.3/fpm/pool.d/www.conf
修改以下幾個設定項目:
pm.max_children = 180
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_request = 10000
systemctl restart php7.3-fpm