Solution: Too Many php processes consume a large amount of memory.

Source: Internet
Author: User

At noon, I configured monitoring on a kvm, but I obviously felt that the machine card couldn't stand it, So I simply checked it.

1. View server Nic traffic

Sar-nDEV210

We can see that the network card traffic is not very large, and the NIC problems are eliminated.

2. View CPU

Top

It can be seen that the CPU usage is not much, but many php-cgi processes are found.

3. view system memory

Free-m

I don't know. I was shocked. The system memory was used up and swap memory was used up. But what programs occupied the memory.

Ps-ef | grep php

View all processes in the current system and filter out php-related processes.

According to statistics, there are nearly 200 php-related processes. How can we reduce these processes?

The answer is yes. In the php-cgi configuration file, you can customize the number of php processes.

Vim/usr/local/php-5.2.17/etc/php-fpm.conf

Search for the max_children field and change the following number to the number of processes to be defined.

By default, there are 256 cards. I changed it to 10 cards.

Pkill php to end all php Processes

/Usr/local/php-5.2.17/sbin/php-fpm start php

View the process

Obviously reduced.

Finally, check the system memory.

When the problem is solved, the system obviously does not feel stuck.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.