2
votes

I've migrated to a new faster server. The old server was handling the site fine after some serious tweaks, the new server though with an extra 2gigs of ram (4 total) is very slow to respond to requests after 2 days of various tweaks. I'm running PHP in FastCGI mode and the error logs are filled with the following errors:

mod_fcgid: can't apply process slot for /var/www/cgi-bin/cgi_wrapper/cgi_wrapper

and a few

mod_fcgid: read data timeout in 200 seconds

CPU hovers at 40% with around ~80 processes spawned, site is super slow, I tried tweaking fcgid.conf but to no avail:

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 200
  FcgidProcessLifeTime 1000
  FcgidMaxProcesses 5
  FcgidMaxProcessesPerClass 10
  FcgidMinProcessesPerClass 0
  FcgidConnectTimeout 8
  FcgidIOTimeout 200
  FcgidInitialEnv RAILS_ENV production
  FcgidIdleScanInterval 20
  FcgidMaxRequestsPerProcess 500
  FcgidBusyTimeout 300

</IfModule>

Any suggestions?

EDIT: top result

Tasks:  94 total,   1 running,  93 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.1%us, 0.0%sy, 0.0%ni, 99.9%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   5379200k total,  1765840k used,  3613360k free,        0k buffers
Swap:        0k total,        0k used,        0k free,        0k cached

93 sleeping????

1
Monitor the connections, not that you're running on a server limit, looks like that you are running out of connections.hakre
i'm also noticing that the processes are slowly creeping back up, now at 100keeg

1 Answers

2
votes

After a long battle with this, I have found that the culprit was old PHP code which slowed down the processing to the point of timeouts. In particular I found that files that used <? instead of <?php tags and were being included in other files had long execution times. Once replaced with the proper <?php. I also downgraded PHP version 5.2.17 to avoid a lot of notices and warnings about deprecated functions. After that the server started flying and the errors stopped.