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 -> Apache View previous topic :: View next topic
Reply to topic   Topic: number of fcgid processes on Windows Server
Author
PanchoJ



Joined: 25 Oct 2012
Posts: 11
Location: Australia

PostPosted: Thu 10 Oct '13 6:54    Post subject: number of fcgid processes on Windows Server Reply with quote

Hi All,

I'm new to fcgid on Windows. my current set up is as follows;

Windows Server 2008
Apache 2.4.4
PHP 5.3.27 (fcgid)
MySQL 5.6.14

1. Looking at windows task manager, each of my processes have 4 threads each. What does this mean?

2. Does the number of FcgidMaxProcesses x memory_limit = Total amount of memory required?

3. Number of Threadsperchild = number of FcgidMaxProcesses ? Sorry for this silly question, i just want to know how these two work together.

Thanks
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3092
Location: Hilversum, NL, EU

PostPosted: Thu 10 Oct '13 10:22    Post subject: Reply with quote

In Taskmanager you should see two httpd.exe processes and the number of threads depends on load/connections/accesses:

Httpd threads is defined:

# ThreadsPerChild: constant number of worker threads in the server process
# MaxConnectionsPerChild: maximum number of connections a server process serves

note: Windows uses mpm_winnt, where there is only one child process. So two httpd.exe processes.


Httpd threadsperchild is not related to mod_fgcid processes/threads.
Back to top
PanchoJ



Joined: 25 Oct 2012
Posts: 11
Location: Australia

PostPosted: Thu 10 Oct '13 11:07    Post subject: Reply with quote

Thanks Steffen,

Makes more sense. However, as per my number 1 question, my php-cgi processes on average have 4 threads each. Does this mean each php-cgi process can handle 4 concurrent requests?

Also, how does threadsperchild and fcgidoutputbuffersize work together. In one of your posts you mention that the fcgid outputbuffer size depends on the threadsperchild setting.

Thanks again
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3092
Location: Hilversum, NL, EU

PostPosted: Thu 10 Oct '13 11:32    Post subject: Reply with quote

PHP with mod_fcgid is Non Thread Safe(NTS, so only one PHP request.

When the server gets busier, then mod_fcgid spawns more php-cgi processes on as needed base. It stops/kills the process when the idle time out is reached (default 300 seconds) or when you have defined the tip below.

Tip:
For php you have to have in your conf:

FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000
FcgidMaxRequestsPerProcess 1000

Explanation, see the heading Special PHP considerations at http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html

Httpd threadsperchild is not related to mod_fgcid buffers/processes/thread
Back to top
PanchoJ



Joined: 25 Oct 2012
Posts: 11
Location: Australia

PostPosted: Thu 10 Oct '13 13:07    Post subject: Reply with quote

Makes more sense

On my server I have 6 cores and 16GB of RAM. Any feedback on the PROCESSES controls would be appreciated.

FcgidConnectTimeout 10
FcgidMaxProcesses 120
FcgidMaxProcessesPerClass 120
FcgidMinProcessesPerClass 3

FcgidOutputBufferSize 64
FcgidMaxRequestsPerProcess 50000 is this too high?
FcgidProcessLifeTime 0
FcgidZombieScanInterval 20
FcgidBusyTimeout 3600
FcgidIOTimeout 600
FcgidIdleTimeout 180
FcgidIdleScanInternal 60
FcgidTimeScore 3
FcgidFixPathinfo 0
FcgidMaxRequestLen 268435456

Also, I get a lot of this errors "mod_fcgid: ap_pass_brigade failed in handle_request_ipc function" any ideas?

Cheers
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Fri 11 Oct '13 16:24    Post subject: Reply with quote

FcgidMaxProcesses and FcgidMaxProcessesPerClass --> this depends how many requests at the same time should be handled. I use 300. Your 120 might be ok for you. If not you can increase it.

FcgidMaxRequestsPerProcess 50000 --> after 50000 requests the apache will eleminate the php process and respawns another. I personally use 0 so it will never die unless I restart apache. You should set FcgidFixPathinfo to 1 (my recommendation).

mod_fcgid: ap_pass_brigade failed in handle_request_ipc function --> You might play with FcgidBusyTimeout and FcgidIOTimeout
Back to top
PanchoJ



Joined: 25 Oct 2012
Posts: 11
Location: Australia

PostPosted: Sat 12 Oct '13 0:24    Post subject: Reply with quote

Thanks James,

The reason why I have set FcgidMaxProcesses and FcgidMaxProcessesPerClass --> to 120 is because my memory_limit is set to 128MB. I run around 10 Drupal instances on a load balanced setup which are CPU and RAM hungry. So 120 * 128 = around 15GB of RAM.

As for FcgidMaxRequestsPerProcess 50000 --> I originally had it @ 0, but it wasn't running good with WINCACHE. The cache was clearing every 2-3 minutes, so i ended up setting it to 50000.

any further advice on the above would be great.The FcgidBusyTimeout and FcgidIOTimeout are making a bit crazy Confused. Do these errors mean that users are getting 500 internal server errors?

Thanks again.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Thu 17 Oct '13 16:59    Post subject: Reply with quote

my settings (working for me)

Code:

<IfModule fcgid_module>
   FcgidConnectTimeout 10
   FcgidMaxProcesses 300
   FcgidMaxProcessesPerClass 300
   FcgidOutputBufferSize 64
   ProcessLifeTime 0
   FcgidMaxRequestsPerProcess 0
   FcgidMinProcessesPerClass 0
   FcgidFixPathinfo 1
   FcgidProcessLifeTime 0
   FcgidZombieScanInterval 20
   FcgidMaxRequestLen 536870912
   FcgidIOTimeout 120
   FcgidTimeScore 3
</IfModule>


Maybe Steffen can tell what his settings are.
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3092
Location: Hilversum, NL, EU

PostPosted: Thu 17 Oct '13 19:10    Post subject: Reply with quote

Using here at AL, same as from the readme from the download here, except the settings for z-push.

Code:
<IfModule fcgid_module>
FcgidInitialEnv PHPRC "d:/servers/apache/conf/"
FcgidInitialEnv PATH "d:/servers/apache/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"

FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000
FcgidMaxRequestsPerProcess 1000
FcgidMaxProcesses 50
FcgidMaxRequestLen 8131072

#z-push for Surge/iPhone needs this:
FcgidIOTimeout  7200
FcgidConnectTimeout 180
FcgidBusyTimeout 7200

</IfModule>
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Sun 20 Oct '13 12:51    Post subject: Reply with quote

James Blond wrote:
my settings (working for me)

Code:

<IfModule fcgid_module>
   FcgidConnectTimeout 10
   FcgidMaxProcesses 300
   FcgidMaxProcessesPerClass 300
   FcgidOutputBufferSize 64
   ProcessLifeTime 0
   FcgidMaxRequestsPerProcess 0
   FcgidMinProcessesPerClass 0
   FcgidFixPathinfo 1
   FcgidProcessLifeTime 0
   FcgidZombieScanInterval 20
   FcgidMaxRequestLen 536870912
   FcgidIOTimeout 120
   FcgidTimeScore 3
</IfModule>


Maybe Steffen can tell what his settings are.


The same settings i use and they work fine too but i have a question that makes me curious regarding this setting "FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 0" i should set that to "0" aswell right ?

Just so it matches with "FcgidMaxRequestsPerProcess 0"


Last edited by C0nw0nk on Sun 20 Oct '13 14:15; edited 1 time in total
Back to top
admin
Site Admin


Joined: 15 Oct 2005
Posts: 692

PostPosted: Sun 20 Oct '13 13:13    Post subject: Reply with quote

FcgidInitialEnv PHP_FCGI_MAX_REQUESTS :

See the tip form Steffen above.
Back to top
PanchoJ



Joined: 25 Oct 2012
Posts: 11
Location: Australia

PostPosted: Mon 21 Oct '13 0:55    Post subject: Reply with quote

What is your apache MPM config?

Thanks, I will test and report back.
Back to top
admin
Site Admin


Joined: 15 Oct 2005
Posts: 692

PostPosted: Mon 21 Oct '13 12:08    Post subject: Reply with quote

Here at AL:

ThreadsPerChild 250
MaxConnectionsPerChild 0

The graphs from today:


Back to top
PanchoJ



Joined: 25 Oct 2012
Posts: 11
Location: Australia

PostPosted: Mon 21 Oct '13 13:33    Post subject: Reply with quote

Thanks admin,

Are you using the ApacheStats module for these graphs? Also, what are is the server specs for AL?

Cheers
Back to top
admin
Site Admin


Joined: 15 Oct 2005
Posts: 692

PostPosted: Mon 21 Oct '13 14:16    Post subject: Reply with quote

What specs you want to hear ?

Indeed you can use ApacheStats from the download page, see http://www.apachelounge.com/viewtopic.php?p=20147 . The mod_fcgid memory is not included in the download there.

But the above graphs are made with mod_watch, RRD perl module, mrtg, routers2. So you can have additional more graphs and features, like per vhost, in/out traffic and some more I cannot recall now. Also the minimum interval can be 2 minutes instead of 5 minutes with ApacheStats. It is more complicated/complex to setup and works only with Perl 5.10. Some time ago you could download it here, but it gave me to many questions/support, so I removed it.
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Mon 21 Oct '13 17:49    Post subject: Reply with quote

admin wrote:
FcgidInitialEnv PHP_FCGI_MAX_REQUESTS :

See the tip form Steffen above.


If you limit the "PHP_FCGI_MAX_REQUESTS" and not "FcgidMaxRequestsPerProcess" wouldn't that cause a 500 error ?

My current config uses these settings and it all seems to be fine.

Code:

LoadModule fcgid_module modules/mod_fcgid.so
<IfModule fcgid_module>
FcgidInitialEnv PHPRC "c:/server/php-5.5.5-nts"
FcgidInitialEnv PATH "c:/server/php-5.5.5-nts;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"
FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 100000
FcgidIOTimeout 3699
FcgidIdleTimeout 10
FcgidMinProcessesPerClass 0
FcgidMaxRequestsPerProcess 100000
FcgidProcessLifeTime 0
FcgidMaxRequestInMem 1
FcgidWin32PreventOrphans On
FcgidMaxRequestLen 1073741824
<Files ~ "\.php$>"
  AddHandler fcgid-script .php
  FcgidWrapper "c:/server/php-5.5.5-nts/php-cgi.exe" .php
</Files>
</IfModule>


Also what happens if i set "FcgidMaxProcessesPerClass" to "0" does anyone know ?
Back to top
PanchoJ



Joined: 25 Oct 2012
Posts: 11
Location: Australia

PostPosted: Tue 22 Oct '13 0:55    Post subject: Reply with quote

admin wrote:
What specs you want to hear ?


RAM And CPU?
Back to top
PanchoJ



Joined: 25 Oct 2012
Posts: 11
Location: Australia

PostPosted: Tue 22 Oct '13 6:56    Post subject: Reply with quote

Hi C0nw0nk,

I noticed that you are using FcgidMaxRequestInMem and FcgidWin32PreventOrphans, can you tell the benefits you have found using these?

Cheers
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Tue 22 Oct '13 22:28    Post subject: Reply with quote

PanchoJ wrote:
Hi C0nw0nk,

I noticed that you are using FcgidMaxRequestInMem and FcgidWin32PreventOrphans, can you tell the benefits you have found using these?

Cheers


Well when i reboot apache it just makes it easier for me to terminate all the php-cgi processes at once and setting max request in memory keeps my apache process memory consumption low.

i think prevent orphans should be enabled by default it is a very useful feature.

I did have a problem that my mod_fcgi under high traffic kept locking up but i fixed that by increasing "fcgidmaxprocessesperclass".

http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html#fcgidmaxprocessesperclass
Being at 100 by default as soon as my server had 100+ php-cgi processes it would just stop serving traffic and timeouts would start occurring so i set it to a high number "9000"

Only increase that value if you have very high traffic i recon because as soon as you go over 100 processes apache will start displaying timeout's (for me it did this anyway)

The traffic that hits my server is over 50million a month (CloudFlare stats)
Back to top


Reply to topic   Topic: number of fcgid processes on Windows Server View previous topic :: View next topic
Post new topic   Forum Index -> Apache