linux apache memory usage is relatively high

Encountered a problem today, I bought Ali cloud server mysql has been kept hang up, the reason is lack of memory, and later added a virtual partition better after a while or not, since they used the apache, had intended to replace the Nginx, In this way it will be smaller memory consumption.

View the current memory usage, use up the top 10 processes:

[root@iZwz9e76n26ksfi0d1skm6Z storage]# ps aux|head -1;ps aux|grep -v PID|sort -rn -k +4|head
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
daemon 23001 0.0 17.2 1135232 332236 ? Sl 04:57 0:22 /usr/local/apache2/bin/httpd -k restart
daemon 23011 0.0 10.5 1121440 202368 ? Sl 04:57 0:15 /usr/local/apache2/bin/httpd -k restart
daemon 23008 0.0 9.9 1121508 192124 ? Sl 04:57 0:17 /usr/local/apache2/bin/httpd -k restart
daemon 23002 0.0 9.3 1085824 180388 ? Sl 04:57 0:13 /usr/local/apache2/bin/httpd -k restart
daemon 23007 0.0 8.4 1118160 161832 ? Sl 04:57 0:17 /usr/local/apache2/bin/httpd -k restart
daemon 23003 0.0 8.1 1134216 156212 ? Sl 04:57 0:19 /usr/local/apache2/bin/httpd -k restart
daemon 23006 0.0 6.7 1105496 129248 ? Sl 04:57 0:12 /usr/local/apache2/bin/httpd -k restart
root 13849 0.4 0.2 153496 5292 ? Ssl May26 78:58 /usr/local/aegis/aegis_client/aegis_10_23/AliYunDun
root 1086 0.0 0.1 255812 2820 ? Sl May25 0:15 /sbin

But finally try an online search about the results really find the reasons.

Modify the following files:

we /usr/local/apache2/conf/extra/httpd-mpm.conf

<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxRequestWorkers 150
MaxConnectionsPerChild 0
</IfModule>

 

The MaxConnectionsPerChild 0 changed: MaxConnectionsPerChild 500, and then look at memory usage is much smaller, problems get.

 

Test Results:

root@iZwz9e76n26ksfi0d1skm6Z extra]# ps aux|head -1;ps aux|grep -v PID|sort -rn -k +4|head
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 2742 0.0 0.6 278492 12996 ? Ss May25 0:49 /usr/local/apache2/bin/httpd -k restart
daemon 9754 0.0 0.4 620616 9460 ? Sl 22:48 0:00 /usr/local/apache2/bin/httpd -k restart
daemon 9753 0.0 0.4 620616 9452 ? Sl 22:48 0:00 /usr/local/apache2/bin/httpd -k restart
daemon 9752 0.0 0.4 620616 9448 ? Sl 22:48 0:00 /usr/local/apache2/bin/httpd -k restart
root 13849 0.4 0.2 153496 5324 ? Ssl May26 78:58 /usr/local/aegis/aegis_client/aegis_10_23/AliYunDun
root 1086 0.0 0.1 255812 2820 ? Sl May25 0:15 /sbin/rsyslogd -i /var/run/syslogd.pid -c 5
root 9841 0.0 0.0 100928 664 pts/2 S+ 22:48 0:00 head
root 9840 0.0 0.0 155440 900 pts / 2 S + 22:48 0:00 sort -rn -k +4
root 9838 0.0 0.0 110240 1172 pts / 2 R + 22:48 0:00 ps aux
root 9 0.0 0.0 0 0? S May25 0:00 events_long / 0]

Memory decline significantly, and then fix the problem, do not change the nginx.

Be the First to comment.

Guess you like

Origin blog.csdn.net/wccczxm/article/details/89379137