Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Web Server
  • Search

php-cgi eat up the memory

Questions regarding the Web Server
Apache + Nginx, Nginx + PHP5-FPM
Post Reply
  • Print view
Advanced search
17 posts
  • Previous
  • 1
  • 2
enterpr1se
Posts: 10
Joined: Fri Mar 14, 2014 5:35 am

Re: php-cgi eat up the memory
  • Quote

Post by enterpr1se » Fri Mar 21, 2014 2:28 am

I think I solved the problem.
I dig many articles and there are some parameter need to add if someone face same problem

Acrossing to the document from apache, http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html
PHP_FCGI_CHILDREN should set to 0 due to any child processes created by PHP will not be used effectively. (Additionally, the PHP child processes may not be terminated properly.)
That's why so many php-cgi process was created but not close properly.
The file location is in /home/YOUR_USER/web/YOUR_WEB/cgi-bin/fcgi-starter

Second, edit /etc/httpd/conf.d/fcgid.conf
these parameter should be added after "LoadModule fcgid_module modules/mod_fcgid.so"

Code: Select all

FcgidMinProcessesPerClass 0 #no process will be created if the user not active
FcgidMaxProcessesPerClass 16 
FcgidMaxProcesses 150
FcgidIdleTimeout 60 #if the process idle 60s will be killed
FcgidProcessLifeTime 120
FcgidIdleScanInterval 30
 

# Change the rate at which new FastCGI processes are spawned under load. Higher=faster
FcgidSpawnScoreUpLimit 10

# Higher number = spawning more FastCGI processes decreases the spawn rate (controls runaway
FcgidSpawnScore 1

# Higher number = terminating FastCGI processes decreases the spawn rate (controls runaway)
FcgidTerminationScore 2

# Increase the FastCGI max request length for large file uploads (needed for some sites)
FcgidMaxRequestLen 1073741824

FcgidMaxRequestsPerProcess 100000
FcgidIOTimeout 1800
REMEMBER BACKUP THE FILE BEFORE YOU EDIT
Top

mephivio
Posts: 198
Joined: Thu Mar 27, 2014 7:35 am

Os: Debian 8x
Web: nginx + php-fpm
Re: php-cgi eat up the memory
  • Quote

Post by mephivio » Mon Apr 14, 2014 5:35 pm

Ok cool
i will test it soon !

But, Imperio, could you confirm the solution proposed by enterpr1se is correct ?

Thx !
Top

imperio
VestaCP Team
Posts: 7000
Joined: Sat Dec 01, 2012 12:37 pm
Contact:
Contact imperio
Website

Re: php-cgi eat up the memory
  • Quote

Post by imperio » Wed Apr 16, 2014 8:13 pm

Hi,
Yes, you can try to use instruction of enterpr1se
if you have any problems let me know
Top

demlasjr
Posts: 74
Joined: Thu Feb 27, 2014 8:50 pm

Re: php-cgi eat up the memory
  • Quote

Post by demlasjr » Sat Apr 19, 2014 10:54 pm

I had the same issue with fastcgid.

As enterpr1se said, the solution is to edit /etc/httpd/conf.d/fcgid.conf (CentOS) or /etc/apache2/mods-available/fcgid.conf (Ubuntu) and will work. I have something like this:

Code: Select all

<IfModule mod_fcgid.c>
  AddHandler    fcgid-script .fcgi
  FcgidConnectTimeout 20
  FcgidMinProcessesPerClass 0
  FcgidMaxProcessesPerClass 10
  FcgidMaxProcesses 50
  FcgidIdleTimeout 60
  FcgidProcessLifeTime 120
  FcgidIdleScanInterval 30


  # Change the rate at which new FastCGI processes are spawned under load. Higher=faster
  FcgidSpawnScoreUpLimit 10

  # Higher number = spawning more FastCGI processes decreases the spawn rate (controls runaway
  FcgidSpawnScore 2

  # Higher number = terminating FastCGI processes decreases the spawn rate (controls runaway)
  FcgidTerminationScore 2

  # Increase the FastCGI max request length for large file uploads (needed for some sites)
  FcgidMaxRequestLen 1073741824

  FcgidMaxRequestsPerProcess 100000
  FcgidIOTimeout 1800
</IfModule>

Then restart the apache.

What will this do? Will limit the processses per class to 10 and max 50 processes in total. Every process will automatically kill after 60 seconds (before never killed itself and used most of the ram in idle). Doing this, you will reduce the ram usage with 70%

Image
Top

Trentor
Posts: 84
Joined: Fri Apr 25, 2014 6:42 pm

Re: php-cgi eat up the memory
  • Quote

Post by Trentor » Tue Aug 26, 2014 11:33 am

Hi,

Thank you enterpr1se and demlasjr, my problem with RAM and php-cgi seems solved.

Thanks!!
Top

iamkingsleyf
Posts: 30
Joined: Sun Nov 23, 2014 4:41 am

Re: php-cgi eat up the memory
  • Quote

Post by iamkingsleyf » Thu Jan 01, 2015 4:24 pm

enterpr1se wrote:I think I solved the problem.
I dig many articles and there are some parameter need to add if someone face same problem

Acrossing to the document from apache, http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html
PHP_FCGI_CHILDREN should set to 0 due to any child processes created by PHP will not be used effectively. (Additionally, the PHP child processes may not be terminated properly.)
That's why so many php-cgi process was created but not close properly.
The file location is in /home/YOUR_USER/web/YOUR_WEB/cgi-bin/fcgi-starter

Second, edit /etc/httpd/conf.d/fcgid.conf
these parameter should be added after "LoadModule fcgid_module modules/mod_fcgid.so"

Code: Select all

FcgidMinProcessesPerClass 0 #no process will be created if the user not active
FcgidMaxProcessesPerClass 16 
FcgidMaxProcesses 150
FcgidIdleTimeout 60 #if the process idle 60s will be killed
FcgidProcessLifeTime 120
FcgidIdleScanInterval 30
 

# Change the rate at which new FastCGI processes are spawned under load. Higher=faster
FcgidSpawnScoreUpLimit 10

# Higher number = spawning more FastCGI processes decreases the spawn rate (controls runaway
FcgidSpawnScore 1

# Higher number = terminating FastCGI processes decreases the spawn rate (controls runaway)
FcgidTerminationScore 2

# Increase the FastCGI max request length for large file uploads (needed for some sites)
FcgidMaxRequestLen 1073741824

FcgidMaxRequestsPerProcess 100000
FcgidIOTimeout 1800
REMEMBER BACKUP THE FILE BEFORE YOU EDIT
Thanks for this solution
Top

DjarumSuper
Posts: 6
Joined: Tue Mar 31, 2015 6:37 pm

Re: php-cgi eat up the memory
  • Quote

Post by DjarumSuper » Wed Apr 01, 2015 3:55 am

Ah this is it

Thank you very much
Top


Post Reply
  • Print view

17 posts
  • Previous
  • 1
  • 2

Return to “Web Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password