Calculate average memory consumption of php-fpm processes

Here is one liner which gives you average memory consumption of php-fpm processes.

 ps --no-headers -o "rss,cmd" -C "php-fpm" |  awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'

If you have more pools, you can grep for specific pool and get average for that one:

 ps --no-headers -o "rss,cmd" -C "php-fpm" | grep <mypool2> |  awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'

Magento: PHP Fatal error – Allowed memory size exhausted when bin/magento module:status

This was strange one. When calling simple magento command with PHP CLI I was getting error that allowed memory size was exhausted.

[root@machine ~]# php bin/magento module:status
[root@machine ~]# PHP Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 32768 bytes) in /path/to/wwww/magentoshot.com/vendor/symfony/console/Application.php on line 951

I checked php.ini and it was set like this:

memory_limit = 2048M

I checked if there are different values for CLI version. It were the same.

Solution was simple. Change your php.ini value for memory_limit and define it in gigabytes instead in megabytes.

memory_limit = 2G

I restarted Apache and it started to work.

© 2024 geegkytuts.net
Hosted by SIEL


About author