• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Resolved FastCGI Config

sharulhafiz

Basic Pleskian
I've tried multiple fastcgi config but all of them failed to handle my server traffic. After some time, the server will start sending 503 bad gateway error. Temporary solution is to restart httpd.

I've made some modification but not sure if it solve the problems since this modification was made after off-peak time (after office hour). Here is my current setting:

Code:
LoadModule fcgid_module modules/mod_fcgid.so

<IfModule mod_fcgid.c>

<IfModule !mod_fastcgi.c>
    AddHandler fcgid-script fcg fcgi fpl
</IfModule>

  FcgidIPCDir /var/run/mod_fcgid/sock
  FcgidProcessTableFile /var/run/mod_fcgid/fcgid_shm

  FcgidIdleTimeout 5
  FcgidProcessLifeTime 30
  FcgidMaxProcesses 300
  FcgidMinProcessesPerClass 0
  FcgidMaxProcessesPerClass 50
  FcgidConnectTimeout 30
  FcgidIOTimeout 45
  FcgidInitialEnv RAILS_ENV production
  FcgidIdleScanInterval 30

</IfModule>

Can anyone could share their config that works? This server only install Wordpress, about 50 of them, multisite enable, WP Super Cache enabled for big network.
 
CPUGenuineIntel, Intel(R) Xeon(R) CPU E5-2620 v2 @ 2.10GHz
VersionParallels Plesk v12.0.18_build1200140606.15 os_CentOS 6
OSCentOS 6.6 (Final)
RAM 32GB
HDD 1T

However, I'd like to highlight that this error is significantly reduced after I configured httpd.conf, using worker MPM
Code:
<IfModule worker.c>
#Old config
#StartServers         2
#MaxClients         300
#MaxClients            1000
#MinSpareThreads     25
#MaxSpareThreads     75
#ThreadsPerChild     25
#MaxRequestsPerChild  0
#ServerLimit            40
# Large Site - new config
ServerLimit 2048
ThreadLimit 100
StartServers 10
MinSpareThreads 30
MaxSpareThreads 100
ThreadsPerChild 64
MaxClients 2048
MaxRequestsPerChild 5000
</IfModule>

Basically, I only have google as references, not yet found any professional advice. Thanks for having a look

update:
found out that this error still available. here is what i found in error log
Code:
mod_fcgid: can't apply process slot for /var/www/cgi-bin/cgi_wrapper/cgi_wrapper
 
Last edited:
I've raised the value from 700 to 1000. Since the changed can't be seen immediately, I will update this topic accordingly.
 
I've followed that page, as seen on my 2nd post. Also, the author also mention about php-fpm. Plesk do support php-fpm but its only turned on if using fully nginx, which i've already given up after numerous trial and error - my sites are fully wordpress.
 
@pleskpanel , there is a lot of running processes, any tips on narrowing it down so that i can paste here?

This comments suggest that 2 things:
  1. set PHP_FCGI_MAX_REQUESTS to the same value as my FcgidMaxProcesses, since default value is 500
  2. instead of using fcgid, use php fpm
here is my current fcgid.conf
Code:
# This is the Apache server configuration file for providing FastCGI support
# via mod_fcgid
#
# Documentation is available at http://fastcgi.coremail.cn/doc.htm

LoadModule fcgid_module modules/mod_fcgid.so

<IfModule mod_fcgid.c>

<IfModule !mod_fastcgi.c>
    AddHandler fcgid-script fcg fcgi fpl
</IfModule>

  FcgidIPCDir /var/run/mod_fcgid/sock
  FcgidProcessTableFile /var/run/mod_fcgid/fcgid_shm

  FcgidIdleTimeout 60
  FcgidProcessLifeTime 120
  FcgidMaxProcesses 10000
  FcgidMinProcessesPerClass 0
  FcgidMaxProcessesPerClass 8
  FcgidConnectTimeout 30
  FcgidIOTimeout 45
  FcgidInitialEnv RAILS_ENV production
  FcgidIdleScanInterval 30

</IfModule>
 
What you are trying to do should be possible without the use of run php-fpm so just with fcgi (barring abnormally high traffic) this is a configuration problem.

Here are a few basic questions to start with:

- What does your httpd file look like?
- Do you have KeepAlive on? (probably a good practice given that your WordPress sites may use numerous image/css/js objects and Ajax calls) but most importantly, what are the KeepAliveTimeout and MaxKeepAliveRequests values set to?
- When the errors are written to the logs what does your memory/CPU usage look like? If it's a configuration issue sometimes you'll actually see relatively low CPU/memory usage since those are not the bottlenecks
- What do you have set for your FcgidMaxRequestsPerProcess value?
- On another note, how many processes are you running?
- Can you run this a few times over the course of your busy periods?

ps aux | grep 'httpd' | awk '{print $6/1024;}' | awk '{avg += ($1 - avg) / NR;} END {print avg " MB";}'
 
- as attached
- KeepAliveTimeout 15 | MaxKeepAliveRequests 100
- when it happens, cpu and memory stays the same (after some configuration update, before this, the server just stall, memory drops to around 10% from 50%, and cpu usage drops, need to restart httpd to make webserver up again)
- FcgidMaxRequestsPerProcess 18000 | FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 18000
- is it total process for whole server?
- 164MB
 

Attachments

  • httpd.conf.txt
    34 KB · Views: 11
Firstly, is this the contents of your /etc/httpd/conf.d/httpd.conf file or the actual server's httpd.conf file? You should be using over-rides in /etc/httpd/conf.d/httpd.conf which will keep your management cleaner and is a best-practices approach to managing it.

- Likely insignificant to performance with the resources that you have but set ServerSignature to Off
- While you have set some associated KeepAlive values, KeepAlive itself is off so turn that on
- Change KeepAliveTimeout to 6
- Comment out your FcgidMaxRequestsPerProcess and add a new line with FcgidMaxRequestsPerProcess 1000
- Save and restart

164 MB is the average size across Apache processes (this could be considered very high depending but it depends on what kind of sites you're running - for WordPress sites that don't use large numbers of plugins or have leaky code I would be shooting for 20-40 MB if possible)

Can you try these steps and post back here?
 
that is the main httpd.conf. i've applied the settings and also a new worker MPM setting as bellow
Code:
<IfModule worker.c>
#StartServers         2
#MaxClients         300
#MaxClients         1000
#MinSpareThreads     25
#MaxSpareThreads     75
#ThreadsPerChild     25
#MaxRequestsPerChild  0
#ServerLimit            40
# Large Site
ServerLimit 40
#ThreadLimit 100
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxClients 1000
MaxRequestsPerChild 0
</IfModule>

new httpd memory is
62.8992 MB
 
received this error
Code:
mod_fcgid: can't apply process slot for /var/www/cgi-bin/cgi_wrapper/cgi_wrappe
changed FcgidMaxRequestsPerProcess from 1000 to 10000

continuing monitor
 
Back
Top