duangong937906 2018-08-26 12:49
浏览 107

sw-engine Plesk Onyx导致内存不足错误

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?

  • 写回答

1条回答 默认 最新

  • douxiangui5011 2018-09-03 15:36
    关注

    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:

    enter image description here

    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
    
    评论

报告相同问题?

悬赏问题

  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况