Increased memory usage by PHP-CGI processes

Created:

2016-11-16 12:49:34 UTC

Modified:

2017-08-08 13:45:26 UTC

1

Was this article helpful?


Have more questions?

Submit a request

Increased memory usage by PHP-CGI processes

Applicable to:

  • Plesk 12.5 for Linux
  • Plesk Onyx for Linux

Symptoms

The memory usage increased after installing Plesk updates.

RAM is used by dozens of php-cgi processes started by Apache:

[root@nove ~]# top
Tasks: 544 total, 2 running, 515 sleeping, 24 stopped, 3 zombie
%Cpu(s): 0.2 us, 0.2 sy, 25.0 ni, 74.0 id, 0.4 wa, 0.0 hi, 0.0 si, 0.1 st
KiB Mem : 14973552 total, 493968 free, 13515832 used, 963752 buff/cache
KiB Swap: 39313404 total, 30470192 free, 8843212 used. 496212 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
26267 ergol1f3 20 0 810324 72704 3372 S 0.0 0.5 0:01.62 /opt/plesk/php/5.3/bin/php-cgi -c /var/www/vhosts/system/example.com/etc/php.ini
10022 orbiimo+ 20 0 809084 71940 2108 S 0.7 0.5 0:01.72 /opt/plesk/php/5.3/bin/php-cgi -c /var/www/vhosts/system/example1.com/etc/php.ini
996 atacado+ 20 0 814800 68728 10556 S 0.0 0.5 0:04.24 /opt/plesk/php/5.3/bin/php-cgi -c /var/www/vhosts/system/example2.com/etc/php.ini
9053 maissab+ 20 0 808016 64660 184 S 0.0 0.4 0:01.39 /opt/plesk/php/5.3/bin/php-cgi -c /var/www/vhosts/system/example3.com/etc/php.ini
26703 adh3r1ng 20 0 808608 60292 1596 S 0.0 0.4 0:01.44 /opt/plesk/php/5.3/bin/php-cgi -c /var/www/vhosts/system/example4.com/etc/php.ini
17043 afkcons+ 20 0 808012 56652 284 S 0.0 0.4 0:01.93 /opt/plesk/php/5.3/bin/php-cgi -c /var/www/vhosts/system/example5.com/etc/php.ini
29810 rr0n3 20 0 808012 49968 224 S 0.0 0.3 0:01.53 /opt/plesk/php/5.3/bin/php-cgi -c /var/www/vhosts/system/example6.com/etc/php.ini

[root@nove ~]# ps -f 29810
UID PID PPID C STIME TTY STAT TIME CMD
apache 3760 3756 0 Aug09 ? S 0:03 /usr/sbin/httpd -DFOREGROUND

Very big timeouts are specified in /etc/httpd/conf.d/fcgid.conf :

  FcgidIdleTimeout 2100
FcgidProcessLifeTime 2100
FcgidMaxProcesses 300
FcgidConnectTimeout 2100
FcgidIOTimeout 2100
FcgidBusyTimeout 2100

Cause

PHP-CGI processes are consuming too much memory due to big timeout values in FastCGI configuration.

Resolution

Two options are possible.

  1. Decrease timeouts to lower values in /etc/httpd/conf.d/fcgid.conf to finish php-cgi processes earlier, and execute service httpd reload command to reload Apache configuration. Default values are:

      FcgidIdleTimeout 40
    FcgidProcessLifeTime 30
    FcgidMaxProcesses 20
    FcgidConnectTimeout 30
    FcgidIOTimeout 45
    FcgidIdleScanInterval 10
  2. Go to PHP settings at Domains > example.com and set PHP version to 7.0.9 and handler to FPM application served by nginx . Perform these configuration changes for every domain one by one.

Note : The drawback for the first option is possible failure of long-running PHP scripts. If you are sure that there is no any on the server, you can follow this option.The drawback of the second option is possible websites' downtime due to switching to nginx. For example, domain-level .htaccess files can not be handled anymore, that can lead to website downtime. That's why it was recommended to switch the websites one by one, checking their availability.

Have more questions? Submit a request

2 Comments

  • 0
    Avatar
    Luca

    Can I changed the service plan with the suggestion 2? Will be the change applied to domains associates?

    Thanks.

     

    Luca

     

     

    Edited by Luca
  • 0
    Avatar
    Alexander Nezymaev

    Hello, Luca!

    If you want to change PHP version and handler in Service Plan and apply it to all the subscription associated with it then proceed with the following:

    1. Ensure that option "PHP version and handler management" is unchecked at the Home > Service Plans > Service plan name > Permissions.

    2. Change PHP setting at Home > Service Plans > Service plan name > PHP Settings.

    3. Press Update & Sync button.

    After that PHP Settings changes will be applied to all the synced subscription which associated with the affected Service Plan.

Please sign in to leave a comment.