Linux troubleshooting process memory usage is too high

A friend said to me, their server memory usage is too high a project, let me help look at how it was. I'm just not too busy to help him read, and recorded as follows.

1 View server status

His server is Ali cloud ECS, the system is CentOS Linux release 7.5.1804 (Core)
top command looked under the system of state
Here Insert Picture Description

Overall system load and cpu is not high, but the memory usage is relatively high (total 8G uses 7.2G).
Use M Sort by memory usage
Here Insert Picture Description

2 Check the memory consumption of up to 40 before the process

ps auxw | head -1; ps auxw | sort -rn -k4 | head -40
Here Insert Picture Description
by the figure can be found in many php-fpm process, using the command ps -ef | grep php-fpm: \ pool \ www | wc - l see this in the number of processes 159
Here Insert Picture Description
each process takes up about 50M, it seems that high memory problems should excessive number of child processes php-fpm pool problem.

3 solution

Through a variety of search, discovery can be configured pm.max_children property, control php-fpm number of child processes, first of all, open the php-fpm configuration file, execute command:
vi /opt/php/php7.2/etc/php-fpm. d / www.conf
found pm.max_children field 100 to modify (originally 300), modified to 30 pm.start_servers colleagues (originally 100).
Then restart php-fpm systemctl restart php-fpm

View memory usage again and found a much reduced memory usage
Here Insert Picture Description

While the number using the php command to view the process of reducing the number
Here Insert Picture Description
Because not quite understand php, non-professional solutions are found from the network, and may not be the best solution.

Published 16 original articles · won praise 1 · views 10000 +

Guess you like

Origin blog.csdn.net/a0604030212/article/details/105043203