My Apache is throwing Internal Server Error 500 errors and logs like this:
> [Sun Apr 07 23:35:24 2013] [error] [client 124.162.30.45] (2)No such
> file or directory: FastCGI: failed to connect to server
> "/home/magda_00aa/sportxxx.pl/sportxxx.pl.0fake": socket file
> descriptor (1063) is larger than FD_SETSIZE (1024), you probably need
> to rebuild Apache with a larger FD_SETSIZE, referer:
> http://www.surf4web.com/surfing.php?id=haoduodeng2012
I've upped FD limits inside:
cat /usr/include/bits/typesizes.h | grep FD
#define __FD_SETSIZE 65536
and
cat /usr/include/linux/posix_types.h | grep FD_SETSIZE
#undef __FD_SETSIZE
#define __FD_SETSIZE 65536
#define __FDSET_LONGS (__FD_SETSIZE/__NFDBITS)
and also
/sbin/sysctl fs.file-max
fs.file-max = 512000
ulimit -n
1000000
but it didn't helped. My Apache is still crashing if more than 350 virtualhosts :/
I'm on CentOS 5.9 64-bit - kernel 3.0.65-1.el5.elrepo
This is because mod_fastcgi uses select() as a multiplexing option. Select is pretty bad for this stuff, the man page specifies for select;
FD_SETSIZE is normally 1024, so file descriptors over 1024 are not supported in general. You can fiddle with the FD_SETSIZE include sizes as you have done but making changes like this might impact other programs too which aim to be POSIX compliant. In my opinion, if the application writer is suggesting altering system source code to make this work then the application is fundamentally broken.
I suggest moving off of mod_fastcgi and using another implementation. Depending on how your staring your FastCGI daemons can depend on how you do this.
mod_fcgid
is one option or newer apaches can usemod_proxy_fcgi
instead.