Current time: 11-23-2024, 10:39 AM Hello There, Guest! (LoginRegister)


Post Reply 
Default fcgid configuration is wrong...
Author Message
kilburn Offline
Development Team
*****
Dev Team

Posts: 2,182
Joined: Feb 2007
Reputation: 34
Post: #1
Default fcgid configuration is wrong...
I've just read through this thread about fcgid process spawning, where it is made clear that mod_fcgid will not use any childs spawned by the php process.

On the other hand, our default configuration looks like:
Quote:#!/bin/sh
umask 022
PHPRC="{PHP_STARTER_DIR}/{DMN_NAME}/php5/"
export PHPRC

PHP_FCGI_CHILDREN=2
export PHP_FCGI_CHILDREN

exec {PHP5_FASTCGI_BIN}

Therefore, we are wasting the memory usage of this second process we're telling php to start.

Finally, the default configuration looks like this:
Code:
<IfModule mod_fcgid.c>
  AddHandler fcgid-script .php .php{PHP_VERSION}
  SocketPath /var/lib/apache2/fcgid/sock
  IdleTimeout 600
  IdleScanInterval 120
  BusyTimeout 300
  BusyScanInterval 120
  ErrorScanInterval 3
  ZombieScanInterval 3
  ProcessLifeTime 900
  SpawnScoreUpLimit 10
  SpawnScore 1  
  TerminationScore 2  
  MaxProcessCount 200
  DefaultMaxClassProcessCount 10  
  DefaultMinClassProcessCount 1
  IPCConnectTimeout 900
  IPCCommTimeout 900
  MaxRequestsPerProcess 500  
</IfModule>

My own tests show that I can set "DefaultMinClassProcessCount 0" without major drawbacks (php websites that are almost never accessed take a bit longer to load, but nothing really annoying), and the memory usage on the server decreases notably.

Admins out there: what do you think about making my prosoed changes new defaults? Any objections?
08-24-2009 04:21 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Nuxwin
Unregistered

 
Post: #2
RE: Default fcgid configuration is wrong...
I'm against ! This config is wrong... See the internal discussion and see your wrapper....
10-19-2010 06:12 PM
Quote this message in a reply
kilburn Offline
Development Team
*****
Dev Team

Posts: 2,182
Joined: Feb 2007
Reputation: 34
Post: #3
RE: Default fcgid configuration is wrong...
This post is more than 1 year old. Therefore, it is superseeded by our internal discussion on which should be the default config...
10-19-2010 06:45 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Minganus Offline
Banned

Posts: 38
Joined: Feb 2011
Post: #4
RE: Default fcgid configuration is wrong...
So, what now most actual and most recommended configuration for mod_fcgid?
09-13-2011 09:38 AM
Find all posts by this user Quote this message in a reply
kilburn Offline
Development Team
*****
Dev Team

Posts: 2,182
Joined: Feb 2007
Reputation: 34
Post: #5
RE: Default fcgid configuration is wrong...
Warning: This is the configuration I like to use in my servers, but there are no guarantees that they are going to work well in your case (you *have* to adjust the min/max processes to prevent too many php5-cgi processes eating all your server's ram). Additionally, this is only tested in Debian squeeze.

First of all, we have to edit the wrapper being called by mod_fcgid. At this aim, start by modifying the *users* wrapper template found in "/etc/ispcp/fcgi/parts/php5-fcgi-starter.tpl":
Code:
#!/bin/sh

umask 022

PHPRC="{PHP_STARTER_DIR}/{DMN_NAME}/php5/"
export PHPRC

TMPDIR="{WWW_DIR}/{DMN_NAME}/phptmp"
export TMPDIR

PHP_FCGI_CHILDREN=0
export PHP_FCGI_CHILDREN

PHP_FCGI_MAX_REQUEST=1000
export PHP_FCGI_MAX_REQUEST

exec {PHP5_FASTCGI_BIN}

Next, we also need to modify the *panel's* wrapper template, that is located in "/etc/ispcp/fcgi/parts/master/php5-fcgi-starter.tpl":
Code:
#!/bin/sh

umask 022

PHPRC="{PHP_STARTER_DIR}/{DMN_NAME}/php5/"
export PHPRC

PHP_FCGI_CHILDREN=0
export PHP_FCGI_CHILDREN

PHP_FCGI_MAX_REQUEST=1000
export PHP_FCGI_MAX_REQUEST

TMPDIR="{GUI_ROOT_DIR}/phptmp"
export TMPDIR

exec {PHP5_FASTCGI_BIN}

Now that the wrappers are properly configured, lets see the mod_fcgid specific settings. These are setup in the "/etc/apache2/mods-enabled/fcgid_ispcp.conf":
Code:
# ispCP ω (OMEGA) a Virtual Hosting Control Panel
# Copyright (C) 2006-2010 by isp Control Panel - http://ispcp.net
#
# Version: $Id: fcgid_ispcp.conf 3498 2010-10-20 06:17:13Z nuxwin $
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.1 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
# License for the specific language governing rights and limitations
# under the License.
#
# The Original Code is "ispCP ω (OMEGA) a Virtual Hosting Control Panel".
#
# The Initial Developer of the Original Code is ispCP Team.
# Portions created by Initial Developer are Copyright (C) 2006-2010 by
# isp Control Panel. All Rights Reserved.
#
# The ispCP ω Home Page is:
#
#    http://isp-control.net
#

<IfModule mod_fcgid.c>

  # MODULE SETUP: Do not change this unless you know what you're doing
  ########################################################################
  AddHandler fcgid-script .php .php5
  SocketPath /var/lib/apache2/fcgid/sock
  FcgidMaxRequestsPerProcess 1000
  FcgidPassHeader Authorization


  # ADMIN PREFERENCES: These control different limits as described below
  # Notice: These settings can be overwritten for a single website by
  # specifying them inside the website's custom configuration file:
  #     /etc/apache2/ispcp/website.tld.conf
  ########################################################################

  # Maximum request time in seconds (a script will be killed if it
  # runs for more time than that)
  FcgidBusyTimeout 300

  # Maximum time before the request generates some data (a script will be
  # killed if it doesn't generate any output before this number of seconds)
  FcgidIOTimeout 300

  # Maximum request lenght in bytes. No request larger than that will ever
  # be procedded, so this has to be higher than the biggest file upload you
  # want to allow.
  FcgidMaxRequestLen 104857600


  # PERFOMANCE SETTINGS: Used to limit the memory requirements
  ########################################################################

  # Maximum number of php5-cgi processes allow to run among all websites
  FcgidMaxProcesses 100

  # Maximum number of php5-cgi processes allowed to run for a single website
  FcgidMaxProcessesPerClass 10

  # Minimum number of php5-cgi processes running for each website. Only set
  # this to 1 or higher if your server has very few domains. Do not set it
  # higher if you have many domains, even if they are rarely accessed, or
  # you will eat up all of the server's RAM and force it to swap to death.
  FcgidMinProcessesPerClass 0

</IfModule>

Finally, you just need to regenerate the configuration files so that your changes to the templates are made effective.
(This post was last modified: 09-13-2011 04:17 PM by kilburn.)
09-13-2011 04:12 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Minganus Offline
Banned

Posts: 38
Joined: Feb 2011
Post: #6
RE: Default fcgid configuration is wrong...
Thanks for info

(09-13-2011 04:12 PM)kilburn Wrote:  Warning: This is the configuration I like to use in my servers, but there are no guarantees that they are going to work well in your case

Can you describe your servers configuration?
CPU, RAM, domains count in panel?


Quote:# Minimum number of php5-cgi processes running for each website. Only set
# this to 1 or higher if your server has very few domains. Do not set it
# higher if you have many domains, even if they are rarely accessed, or
# you will eat up all of the server's RAM and force it to swap to death.

Great description! Smile
(This post was last modified: 09-13-2011 06:58 PM by Minganus.)
09-13-2011 06:51 PM
Find all posts by this user Quote this message in a reply
kilburn Offline
Development Team
*****
Dev Team

Posts: 2,182
Joined: Feb 2007
Reputation: 34
Post: #7
RE: Default fcgid configuration is wrong...
Quote:Can you describe your servers configuration?
CPU, RAM, domains count in panel?

I can (Core i5, 8Gb, 250 domains), but this is not useful to anyone. You have to play with the parameters and see by yourself which are the sane values for your own server.

Basically, the most important aspect of setting up mod_fcgid is to keep the memory usage at bay. Therefore, what I would do is repeatedly trying to increase the maximum number of processes and testing how well the server handles it. "Receipt":
Code:
1. Set "FcgidMaxProcessesPerClass" to #X#, a number of processes that you think your server is going to handle well.
2. From another machine, run 'ab -c #X# -n1000 "http://domain.in/your/server/"'
3. Monitor the server, making sure that #X# php5-cgi processes are spawned for the domain under stress and that it doesn't eat all your memory.
4. The objective is to have approximately 200-300 free Mb of memory when all the processes have spawned.
5. If you have more free memory, go back to 1 with an increased #X#
6. If you have less free memory, go back to 1 with a decreased #X#
7. Once you reach this "sweet spot" (200-300 free Mb under load), you know the *total* maximum of php5-cgi processes that your server can handle.
8. Set "FcgidMaxProcessesPerClass" to a number lower than that, so no single website can completely exhaust the server.
9. Set "FcgidMaxProcesses" to #X#, so that you don't eat up all the ram when there's more than one website under heavy load.
09-13-2011 07:54 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Minganus Offline
Banned

Posts: 38
Joined: Feb 2011
Post: #8
RE: Default fcgid configuration is wrong...
Simple and useful manual!
I will try to use it.
09-13-2011 08:20 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)