fbpx
Search
Close this search box.

How To Diagnose Out Of Memory Killed PHP-fpm Error?

Table of Contents

Get up to 50% off now

Become a partner with CyberPanel and gain access to an incredible offer of up to 50% off on CyberPanel add-ons. Plus, as a partner, you’ll also benefit from comprehensive marketing support and a whole lot more. Join us on this journey today!

In this post, we’ll explain how to diagnose out of memory killed php-fpm and how to stop PHP-FPM in Linux from using up too much or all of your system memory (RAM).

You notice that your web servers have been sluggish, and finally stopped responding when you log in. it indicates that the system’s RAM is low and that PHP fpm has used up the majority of the RAM.

What is PHP-FPM?

FastCGI Process Manager, or fpm in PHP, is a pattern of execution with various capabilities that have a significant impact on how quickly websites load. PHP has an advanced processing capability called Fpm that gracefully starts any task and then quietly ends it without interfering. This feature also has the capacity to adjust to any working environment, including ports, logging patterns, file uploading with support for certain functions, and flushing data to complete requests in accordance with the configuration files available at the time of deployment.

PHP-FPM features

The most widely used alternative to PHP FastCGI is PHP-FPM. It offers extra capabilities that are particularly helpful for websites with significant traffic. Here are a few examples:

  • Processes may be simply started and stopped thanks to advanced management.
  • It replaces safe mode and offers the ability to launch workers with various uid, gid, chroot, environments, and php.ini.
  • logging on stderr and stout.
  • Setting up the slowlog variables will allow you to identify the functions that take longer than usual to complete.
  • based on configuration files for PHP.
  • Improvements to FastCGI include fastcgi finish request(), a unique function that stops and downloads all data while you continue to work on a lengthy process like transcoding videos or analysing statistical data.
  • (Similar to Apache’s mod status module) Basic statistics
  • In case the opcode cache is unintentionally destroyed, an emergency restart is required.
  • accelerated upload support.

Advantages of PHP-FPM

The biggest advantage of utilizing PHP-FPM is that it consumes significantly less memory and CPU than alternative ways to execute PHP. The main justification for this is that it demonizes PHP, making it a background process while still offering a CLI tool for controlling PHP requests. Other advantages include;

  • Security
  • Versatility
  • Performance
  • Reliable
  • Configurable
  • stability

PHP-FPM applications in a variety of domains

  • Web applications to reduce the time it takes for a web page to load by as much as possible.
  • A program that uses PHP-fpm to monitor several hosts worldwide.

NGINX and PHP-FPM

The ideal complement for PHP-FPM is NGINX, a dependable high-performance web server with very low resource usage. Based on events, Nginx offers an asynchronous design that is significantly more scalable. Additionally, performance at the level of memory usage is enhanced while utilizing Nginx and PHP-FPM.

Tech Delivered to Your Inbox!

Get exclusive access to all things tech-savvy, and be the first to receive 

the latest updates directly in your inbox.

Using PHP-FPM, PHP operates as a separate service. Requests are processed through a TCP/IP socket when this version of PHP is used as the language interpreter, leaving the Nginx web server to handle only HTTP requests while PHP-FPM interprets the PHP code. The existence of two distinct services is essential for boosting productivity.

What is “out of memory killed php fpm” error?

This error will occur when you see that your web servers have become slow and have eventually stopped responding on logging into the server. it means that the system is running low on RAM and PHP fpm has consumed most of the RAM

You will see something like this;

Diagnose Out Of Memory Killed PHP-fpm Error

How PHP fpm works?

PHP-FPM implements a server-level cache that may be immediately reused if the request is re-executed since the invoked components and statements are saved in memory (See also OPcache ). Because of this, the PHP file is requested considerably less frequently, resulting in a lower computer load (load average) and greater resource availability so that it can handle other tasks.

Within the same “worker pool,” PHP-FPM can activate “child processes,” entirely isolating the operation of one php script from another. These settings are made in the “pool” file; the pool “www” is selected by default.

As seen in the figure below, the web server basically sends a PHP request to the PHP-fpm, which then sends it to one of its offspring and continues until the response is received:

How To Diagnose Out Of Memory Killed PHP-fpm Error?

How to diagnose out of memory killed PHP-fpm error?

This issue may be resolved by altering the pool configuration file to decrease the memory consumption of the PHP-FPM process manager and certain of its components.

Depending upon the control panel you use, your system configuration file for PHP-FPM will be different. We are using Bitname packaged OS from LightSail.

First of all we need find our pool file and its location, in case of Bitname packed OS, the location us /opt/bitname/php/etc/php-fpm.d

Now that you have the pool file and its location, let us check out the content of the file

Enhance Your CyerPanel Experience Today!
Discover a world of enhanced features and show your support for our ongoing development with CyberPanel add-ons. Elevate your experience today!

Now we need to find the following directives in this pool file and set their value to suit your use case.

for that use the command

Values:

Conclusion

This article has discussed how to identify PHP-FPM memory problems and how to stop PHP-FPM for Linux from using up all of your system memory (RAM).

Upon logging in, you find that your web servers have been sluggish and eventually non-responsive. It demonstrates that the computer has a little amount of RAM and that PHP fpm has used up most of it.

This issue may be resolved by altering the pool configuration file to decrease the memory consumption of the PHP-FPM process manager and certain of its components.

Editorial Team

Unlock Benefits

Become a Community Member

SIMPLIFY SETUP, MAXIMIZE EFFICIENCY!
Setting up CyberPanel is a breeze. We’ll handle the installation so you can concentrate on your website. Start now for a secure, stable, and blazing-fast performance!