I'm trying to run a large php-scipt that starts every hour if the one before is already finished.
Now I'm getting Out of Memory errors and if I analyze "top" the sw-engine task is consuming a lot of memory and this memory isn't freed anytime. Installed Plesk Onyx Version 17.8.11 Update #17 - using php 7.2.9.
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
4626 psaadm 20 0 8838088 8.195g 17344 S 1.7 34.1 9:23.35 sw-engine
Any idea on how to get rid of the sw-engine consuming all the ressources?
Why is sw-engine consuming ressources when I simply start a scheduled task?
sw-engine
is a PHP-FPM handler, which is used by Plesk internally, to run, for example, Plesk UI and PHP scripts as scheduled tasks:
# sw-engine -v
PHP 7.1.14 (cli) (built: Apr 9 2018 16:55:38) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
Instead of sw-engine
, you can use any PHP version installed on the server. For example, /usr/bin/php
for PHP provided by OS vendor, or /opt/plesk/php/7.2/bin/php
for PHP 7.2 shipped with Plesk.
To do that, simply create a scheduled task with Run a command
type, and prepend the path to the script with the path to PHP executable:
As per OOM issue, sw-engine
uses 256 MB memory limit by default:
# grep limit /usr/local/psa/admin/conf/php.ini
memory_limit = 256M
So it looks like the memory limit is redefined somewhere in the script itself. You can verify if as follows:
# grep -i memory_limit /path/to/script.php
Also, you can try to run it manually to see how it performs with different PHP versions to see if there is any difference:
# /usr/bin/php /path/to/script.php
# /usr/sbin/php-fpm /path/to/script.php
# /usr/sbin/sw-engine-fpm /path/to/script.php
# /opt/plesk/php/7.2/bin/php /path/to/script.php