Home Operation and Maintenance CentOS What to do if there are too many php fpm processes in CentOS 7

What to do if there are too many php fpm processes in CentOS 7

Aug 19, 2020 am 09:23 AM

Solution to too many php fpm processes: first check the total number of php processes; then list the top 50 processes that consume the most memory; then optimize "php-fpm" by modifying the configuration file; finally restart the server. Can.

What to do if there are too many php fpm processes in CentOS 7

Recommended: "PHP Video Tutorial"

Solve the problem of too many php-fpm processes in CentOS 7 Many problems lead to large consumption of server memory resources

What is php-fpm:

php-fpm is the FastCGI process manager, which is used to control the memory and processes of php.

Operating environment:

CentOS 7

Problem check:

First check the total number of php processes:

pstree|grep php-fpm
Copy after login

Echo:

|-php-fpm---20*[php-fpm]
Copy after login

According to the echo information, there are 20 php-fpm processes during the query.

You can also use the following command to list the top 50 processes that consume the most memory:

ps auxw|head -1;ps auxw|sort -rn -k4|head -50
Copy after login

Solution process:

Next we optimize php-fpm by modifying the configuration file , to achieve the purpose of reducing memory usage.

My php-fpm configuration file is in the .../server/php/etc/ directory, enter this directory.

Back up the original configuration file first:

cp php-fpm.conf php-fpm.conf.bak
Copy after login

Note: After using vim to open the configuration file, press the Esc key, then enter "/", and then enter "xxx" to search for "xxx" String.

The specific configuration parameters are as follows:

pm.max_children = 100改为:pm.max_children = 25
pm.start_servers = 20改为pm.start_servers = 5
pm.min_spare_servers = 5改为pm.min_spare_servers = 2
pm.max_spare_servers = 35改为pm.max_spare_servers = 10
Copy after login

Restart the server:

reboot
Copy after login

After restarting, you can find that the memory usage is lower than before.

Note:

Explanation of the role of parameters in php-fpm.conf:

pm.max_children: The number of php-fpm processes opened in static mode.

pm.start_servers: The number of starting php-fpm processes in dynamic mode.

pm.min_spare_servers: The minimum number of php-fpm processes in dynamic mode.

pm.max_spare_servers: The maximum number of php-fpm processes in dynamic mode.

When making the above settings, I set the execution mode of php-fpm to dynamic:

pm = dynamic

php-fpm has two execution modes:

One is Static and the other is Dynamic. If set to static, only the pm.max_children parameter will take effect. If set to dynamic, the three parameters pm.start_servers, pm.min_spare_servers and pm.max_spare_servers will take effect. After setting it to dynamic, when php-fpm starts, it will start the corresponding number of processes according to the parameter setting of pm.start_servers. After that, the number of processes of php-fpm will be maintained between the number specified by pm.min_spare_servers and pm.max_spare_servers.

How to choose to use the static or dynamic execution mode of php-fpm:

The dynamic php-fpm execution mode allows php-fpm to release redundant processes, thus saving memory resources.

The static php-fpm execution method does not allow php-fpm to release more than processes, which avoids frequently starting or stopping the php-fpm process, thereby reducing the server's response time in some cases.

The above is the detailed content of What to do if there are too many php fpm processes in CentOS 7. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to restart the server via command line in CentOS system How to restart the server via command line in CentOS system Mar 05, 2025 pm 03:30 PM

This article explains how to restart a CentOS server using the command-line reboot command. It emphasizes the importance of saving data and gracefully shutting down applications before using sudo reboot to avoid data loss. Potential risks, includin

How to restart the network service in centos8 How to restart the network service in centos8 Mar 05, 2025 pm 03:29 PM

This guide details methods for restarting network services in CentOS 8. It compares using systemctl (recommended for reliability) with ifdown/ifup (faster, less robust). Troubleshooting steps for network outages are also provided, covering connecti

What are the centos restart commands What are the centos restart commands Mar 05, 2025 pm 03:28 PM

This article explains CentOS server reboot commands. It focuses on reboot for immediate restarts and shutdown -r for scheduled reboots, highlighting the differences and best practices for each. The main issue is providing clear instructions and con

How to shut down and restart centos7 shutdown and restart command How to shut down and restart centos7 shutdown and restart command Mar 05, 2025 pm 03:24 PM

This guide details safe shutdown and reboot methods for CentOS 7 servers. It emphasizes using the shutdown command for its flexibility and ability to schedule restarts, contrasting it with the less-flexible reboot and halt commands. Safe practices

Centos official website entrance Centos official website entrance Mar 05, 2025 pm 03:32 PM

This article discusses the discontinuation of CentOS and its replacement by CentOS Stream. It details how to find information, downloads, and verify the integrity of CentOS Stream ISOs, now primarily hosted on the Red Hat website. Community support

How do I configure log rotation in CentOS? How do I configure log rotation in CentOS? Mar 17, 2025 pm 04:43 PM

The article explains how to configure log rotation in CentOS using logrotate, detailing installation, configuration, and benefits like disk space management and security.

How do I install and configure MySQL/MariaDB on CentOS? How do I install and configure MySQL/MariaDB on CentOS? Mar 17, 2025 pm 04:35 PM

Article discusses installation, configuration, and troubleshooting of MySQL/MariaDB on CentOS, including system requirements and security measures.(159 characters)

How do I use Logical Volume Management (LVM) in CentOS to manage storage? How do I use Logical Volume Management (LVM) in CentOS to manage storage? Mar 17, 2025 pm 04:51 PM

The article discusses using Logical Volume Management (LVM) in CentOS for efficient storage management, detailing steps for setup, extension, and backup/restore processes, and highlighting LVM's advantages over traditional partitioning.

See all articles