logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Third-party Modules View previous topic :: View next topic
Reply to topic   Topic: mod_fcgid disable process killing
Author
gijs



Joined: 27 Apr 2012
Posts: 189
Location: The Netherlands

PostPosted: Wed 03 Apr '13 1:33    Post subject: mod_fcgid disable process killing Reply with quote

Hi,

I have a server with a lot of ram(32Gb,30% used) and noticed that my php processes get killed after a few minutes of inactivity.
I don't want this because this also clears my php wincache ram cache which speeds up my website.

This is how I have my mod fcgid setup:

<IfModule mod_fcgid.c>
AddHandler fcgid-script .fcgi .php
# Where to look for the php.ini file?
FcgidInitialEnv PHPRC "C:/Progra~2/php"
FcgidInitialEnv PATH "C:/Progra~2/php;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;"
FcgidInitialEnv SystemRoot "C:/Windows"
FcgidInitialEnv SystemDrive "C:"
FcgidInitialEnv TEMP "C:/WINDOWS/Temp"
FcgidInitialEnv TMP "C:/WINDOWS/Temp"
FcgidInitialEnv windir "C:/WINDOWS"
# Set PHP_FCGI_MAX_REQUESTS to greater than or equal to FcgidMaxRequestsPerProcess
# to prevent php-cgi process from exiting before all requests completed
FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1500
# Maximum requests a process should handle before it is terminated
FcgidMaxRequestsPerProcess 0
# Maximum number of PHP processes
FcgidMaxProcesses 15
FcgidOutputBufferSize 131072
FcgidProcessLifeTime 0
FcgidMinProcessesPerClass 1
FcgidMaxRequestLen 1073741824
FcgidProcessLifeTime 0
FcgidZombieScanInterval 20
FcgidMinProcessesPerClass 1
# Number of seconds of idle time before a php-cgi process is terminated
FcgidIOTimeout 64
FcgidIdleTimeout 40
FcgidConnectTimeout 16
<Files ~ "\.php$">
Options Indexes FollowSymLinks ExecCGI
AddHandler fcgid-script .php
FcgidWrapper "C:/Progra~2/php/php-cgi.exe" .php
</Files>
</IfModule>

How can I stop it from killing the php processes if my websites haven't loaded in a little while?
Also I'd like to optimize this config for more performance if possible.
Back to top
CamaroSS



Joined: 24 Jan 2013
Posts: 78
Location: RF, Tver

PostPosted: Wed 03 Apr '13 8:38    Post subject: Reply with quote

You've set PHP_FCGI_MAX_REQUESTS to 1500, it means that PHP process itself won't handle more than 1500 requests. Set it to 0 to disable this mechanism.
FcgidIdleTimeout 40 means that the process will be terminated after 40 seconds of inactivity. Set it to 0.
For more info refer to the official mod_fcgid docs.
Personally, I think it's better to recycle FastCGI processes from time to time.
Back to top
gijs



Joined: 27 Apr 2012
Posts: 189
Location: The Netherlands

PostPosted: Wed 03 Apr '13 15:30    Post subject: Reply with quote

Thanks I will put the FcgidIdleTimeout to 0 and increase the PHP_FCGI_MAX_REQUESTS to 2000

What would you recommend to be the optimum time to recycle a FastCGI process?
Once a day?
Back to top
CamaroSS



Joined: 24 Jan 2013
Posts: 78
Location: RF, Tver

PostPosted: Thu 04 Apr '13 9:06    Post subject: Reply with quote

Well, my FastCGI performance setup is

Code:

FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 18000

FcgidMaxRequestLen 20971520
FcgidMaxRequestInMem 5242880
FcgidOutputBufferSize 4194304
FcgidMaxRequestsPerProcess 18000
FcgidMinProcessesPerClass 5
FcgidMaxProcesses 96
FcgidSpawnScoreUpLimit 6
FcgidTimeScore 2
FcgidConnectTimeout 5
FcgidIOTimeout 235
FcgidIdleTimeout 30
FcgidIdleScanInterval 15
FcgidBusyTimeout 245
FcgidBusyScanInterval 20
FcgidErrorScanInterval 3
FcgidZombieScanInterval 1800
FcgidProcessLifeTime 0


18000 requests are processed in my environment in nearly 1 hour, according to the stats. Moreover, the process can be successfully terminated on SIGTERM when PHP_FCGI_MAX_REQUESTS = FcgidMaxRequestsPerProcess and both are > 0.
I also consider process spawn rate and idle timeout.

If you don't need this, you can just set
PHP_FCGI_MAX_REQUESTS,
FcgidMaxRequestsPerProcess,
FcgidIdleTimeout
to zero and set FcgidProcessLifeTime to something like 3600, so the process will serve for 1 hour.

Also adjust FcgidBusyTimeout and FcgidIOTimeout depending on presence of long-running scripts on your server (like big file uploads etc.) .
Back to top


Reply to topic   Topic: mod_fcgid disable process killing View previous topic :: View next topic
Post new topic   Forum Index -> Third-party Modules