Home > Backend Development > PHP Problem > php process does not release memory

php process does not release memory

(*-*)浩
Release: 2023-02-24 19:48:01
Original
4376 people have browsed it

Solve the problem that the php-fpm process does not release memory

php process does not release memory

##By reducing php- The total number of fpm processes can be used to reduce the memory usage of php-fpm. During actual use, it was found that the php-fpm process still has the problem of long-term memory occupation without releasing it. The solution is to reduce the number of pm.max_requests. (Recommended learning: PHP programming from entry to proficiency)

Maximum number of requests max_requests, that is, when the number of requests processed by a PHP-CGI process accumulates to max_requests, it will automatically restart This process achieves the purpose of releasing memory. Take the VPS host setting of 1GB memory as an example (if the value you set does not reach the free memory, you can continue to lower it):

pm.max_requests = 500
Copy after login

When the php-fpm process reaches the value set by pm.max_requests, it will Restart the process, thereby freeing up memory. The picture below is the result after my test. It can be seen that the php-fpm process was forcibly terminated and the memory was released.

php process does not release memory

For large memory and concurrency and availability requirements, it is recommended to use the static management mode with the largest pm.max_children. If it is a server with small memory, it is recommended to use dynamic or ondemand mode and reduce the number of pm.start_servers and pm.max_spare_servers processes.

The above is the detailed content of php process does not release memory. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template