Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What if the memory occupied by php-fpm is too large?

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

The main content of this article is to explain "what to do if php-fpm takes up too much memory". Interested friends might as well take a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "what if the memory occupied by php-fpm is too large?"

This article operating environment: windows10 system, PHP7, thinkpad T480 computer.

The solution to the problem of excessive memory footprint of php-fpm is as follows:

Method 1: adjust the management mode

Static management mode is suitable for servers with large memory, while dynamic is suitable for servers with small memory. You can set a reasonable range of pm.min_spare_servers and pm.max_spare_servers, so that the number of processes will change constantly. Ondemand mode is more suitable for small memory, such as 512MB or 256MB memory, as well as environments that do not require high availability.

Method 2: reduce the number of php-fpm processes

If your VPS host is running out of memory, you can check the number of your php-fpm processes, according to the number of php-fpm processes = memory / 2 php-fpm 30 to calculate, 1GB memory suitable for the number of php-fpm processes between 10-20, but also according to your PHP loaded add-ons.

Php-fpm configuration example

Here to 1GB memory VPS configuration php-fpm as a demonstration, the actual operation to set the value has to be based on the server's own performance, PHP and other comprehensive considerations.

Pm = dynamic # dynamic and ondemand are suitable for small memory. It takes effect in pm.max_children = 15 # static mode, but dynamic does not. Pm.start_servers = the number of processes booted in 8 # dynamic mode. Pm.min_spare_servers = minimum number of php-fpm processes in 6 # dynamic mode. Pm.max_spare_servers = maximum number of php-fpm processes in 15 # dynamic mode. At this point, I believe you have a deeper understanding of "what to do with too much memory occupied by php-fpm". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report