mod_fcgid: read data from fastcgi server error

Hello all.
I am trying to look into this error msg I am getting, almost all, from bots, 2 or 3 /hour average.

[Tue Aug 09 11:58:08 2011] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Tue Aug 09 11:58:08 2011] [error] [client 66.249.72.206] Premature end of script headers: file.php

Sometimes it displays a referrer from google.
http://www.google.com/url?sa=t&source=web&cd=1&ved=0CBkQFjAA&url=http%3A%2F%2Fwww
I reproduce the url and it load in a half second.

I cannot realize what is the problem or at least how to make a research.
Maybe a punctual excess of concurrent queries from bots?
Anyway would reflect this behavior in 1 load time, isn’t it?
I need some clues please.
Thanks in advance.

Linux 2.6.18-238.19.1.el5xen on x86_64
Intel E7500 Core(s) 2 Speed 2.93GHz

top - 12:38:32 up 6 days, 3:05, 1 user, load average: 2.33, 2.34, 2.37
Tasks: 186 total, 3 running, 183 sleeping, 0 stopped, 0 zombie
Cpu(s): 51.1%us, 13.0%sy, 0.0%ni, 24.3%id, 10.1%wa, 0.0%hi, 0.5%si, 1.0%st
Mem: 2429952k total, 2354396k used, 75556k free, 72508k buffers
Swap: 4192944k total, 382600k used, 3810344k free, 1411516k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
32035 apache 16 0 233m 69m 8164 S 33.6 2.9 0:10.55 php-cgi
31938 apache 16 0 197m 33m 8164 S 9.3 1.4 0:28.07 php-cgi
9852 mysql 15 0 358m 76m 4644 S 7.7 3.2 454:47.61 mysqld
31612 apache 17 0 202m 39m 8164 S 7.7 1.6 0:43.39 php-cgi
12967 apache 19 0 33464 10m 1636 R 3.0 0.4 0:00.09 exiftool
31940 apache 18 0 203m 39m 8164 S 2.3 1.7 0:34.38 php-cgi
10052 root 24 0 67112 1048 780 S 1.7 0.0 36:44.48 searchd
6796 apache 16 0 201m 37m 8156 S 1.0 1.6 0:16.52 php-cgi
28317 apache 15 0 365m 4884 1936 S 1.0 0.2 0:01.17 httpd
295 root 10 -5 0 0 0 S 0.7 0.0 4:56.10 kjournald
2056 apache 15 0 365m 4776 1904 S 0.7 0.2 0:00.79 httpd
5805 apache 15 0 365m 4788 1900 S 0.7 0.2 0:00.54 httpd
6936 apache 15 0 365m 4864 1908 S 0.7 0.2 0:00.57 httpd
28277 apache 15 0 365m 4836 1920 S 0.7 0.2 0:01.09 httpd
6935 apache 15 0 365m 4760 1896 S 0.3 0.2 0:00.43 httpd
6991 apache 15 0 365m 4748 1900 S 0.3 0.2 0:00.40 httpd
8543 root 15 0 92000 5256 2700 S 0.3 0.2 0:01.46 sshd
28276 apache 15 0 365m 4936 1916 S 0.3 0.2 0:01.26 httpd
28278 apache 15 0 365m 4848 1932 S 0.3 0.2 0:01.34 httpd
32318 apache 15 0 365m 4948 1932 S 0.3 0.2 0:00.98 httpd
1 root 15 0 10368 584 552 S 0.0 0.0 0:00.68 init

Hmm, well, I’m not sure what might cause that. It’s certainly possible it’s related to too many bots hitting your sites at once. FCGID can sometimes generate errors if a user or bot leaves before the script finishes executing, though the message is usually different than that.

Have any users ever complained about your site not working?

If it’s a FCGID specific problem, you might want that all those warnings go away simply by switching your site over to CGI. You can do that by going into Server Configuration -> Website Options, and changing the PHP Execution Mode.

You may also want to make sure there aren’t other messages in the error_log before or after the warning that you saw.

-Eric

Howdy,

Well, one of the causes of the above error is a script that takes too long to run… you could always try increasing the timeout for PHP and FCGID by going into Server Configuration -> Website Options for this particular domain, and set “Maximum PHP script run time” to a higher value.

It defaults to 30 seconds, you could try setting it to 45 seconds to see if that makes a difference.

Again, there’s usually a different error when a timeout is occurring, but FCGID can sometimes be fickle in the error messages it gives, so it may be worth trying a timeout change :slight_smile:

-Eric

Hi Eric,
I have no complains, websites are loading fast.
I use tail -f so I am seeing error log in real time, no other errors but ‘ap_pass_brigade failed in handle_request function’ and isolated 404

httpd error log displays

[Wed Aug 17 09:54:28 2011] [notice] mod_fcgid: process /path-to/file.php(5932) exit(communication error), terminated by calling exit(), return code: 0
[Wed Aug 17 09:54:36 2011] [notice] mod_fcgid: call /path-to/file.php with wrapper /path-to-user1-home/fcgi-bin/php5.fcgi
[Wed Aug 17 09:54:37 2011] [notice] mod_fcgid: call /path-to/file.php with wrapper /path-to-user1-home/fcgi-bin/php5.fcgi
[Wed Aug 17 09:54:37 2011] [notice] mod_fcgid: call /path-to/file.php with wrapper /path-to-user1-home/fcgi-bin/php5.fcgi
[Wed Aug 17 09:56:34 2011] [notice] mod_fcgid: process /path-to/file.php(6366) exit(server exited), terminated by calling exit(), return code: 0
[Wed Aug 17 09:56:52 2011] [notice] mod_fcgid: process /path-to/file.php(6321) exit(server exited), terminated by calling exit(), return code: 0
[Wed Aug 17 09:58:47 2011] [notice] mod_fcgid: process /path-to/file.php(5952) exit(server exited), terminated by calling exit(), return code: 0
[Wed Aug 17 09:58:53 2011] [notice] mod_fcgid: process /path-to/file.php(5931) exit(server exited), terminated by calling exit(), return code: 0

During this time period I get from Virtualmin user1
[Wed Aug 17 09:54:25 2011] [error] [client 66.249.72.59] Premature end of script headers: file.php
[Wed Aug 17 09:59:24 2011] [warn] (103)Software caused connection abort: mod_fcgid: ap_pass_brigade failed in handle_request function

I don’t know about this.

Note: This server contains only one VS with hard use of resources. There are a few others with low profile

Thanks for your helo

In regards to this error:

[Wed Aug 17 09:56:52 2011] [notice] mod_fcgid: process /path-to/file.php(6321) exit(server exited), terminated by calling exit(), return code: 0

That can occur if PHP is calling the “exit” function.

FCGID keeps PHP applications cached in memory, and isn’t expecting them to call “exit”.

While that’s not a problem, it’s preventing FCGID from being able to cache that particular application.

If it’s an application you control, you may want to remove the “exit” call.

If it’s not your application, you may want to switch the PHP Execution Mode to CGI rather than FCGID, which will stop some of those messages.

-Eric

Eric,

I had in the past in my virtualmin error log some execution time problems but they have disappeared after some changes.

Unreachable number of pages from crawls errors - Google webmaster tools have been constantly decreased after that fix. All the are about file.php the most accessed page.

From two days ago I am recording query strings in a mysql table from those unfinished accesses to file.php
I got 570 from 747,000
Very low percentage but no sense for me.
Any of those 570 I’ve tested load very fast anytime.
Lot of simultaneous bot access? I don’t think so because those Premature end of script headers errors do not come in a bunch.

Anyway I’ve changed yesterday IPCCommTimeout but no error changes

IPCConnectTimeout 20
#IPCCommTimeout 46
IPCCommTimeout 300

I don’t know about httpd general errors.
From your last post, do you mean
[Wed Aug 17 09:56:52 2011] [notice] mod_fcgid: process /path-to/file.php(6321) exit(server exited), terminated by calling exit(), return code: 0
could be because of exit(); in my php script?
If so, then I don’t care about them. If the query string is malformed then I forward the user to another page using header() and exit().
Could Premature end of script headers errors be because of this too?

Thank you very much

From your last post, do you mean
[Wed Aug 17 09:56:52 2011] [notice] mod_fcgid: process /path-to/file.php(6321) exit(server exited), terminated by calling exit(), return code: 0
could be because of exit(); in my php script?

Yup! That FCGID notice isn’t actually an error, it’s just notifying you that file.php called the “exit()” function.

Well, rather than just changing “IPCCommTimeout”, you may want to change the PHP timeout as well, or else you could be seeing FCGID notices due to PHP timing out. That’s in Server Configuration -> Website Options -> “Maximum PHP script run time”.

The “Premature end of script headers” error simply means that the application ended before Apache expected it to, there’s a lot of potential causes for that. Could that be related to calling exit()? Maybe, but I’m not certain :slight_smile:

-Eric

So I don’t have to care about those httpd general log warnings.
file.php w/o query string is candidate to be forwarded to another page. I tested it and did not get anything in virtualmin/error_log
“Maximum PHP script run time” is already set to 299 ( I did not change it).

I’ve been reading about premature end of script header. Most of users getting this problem have a big one not just isolated cases like mines.
I did not get a clue from them.
I understand that some of unfinished script execution may come from user abortion. If I am not wrong, they are logged as “Software caused connection abort: mod_fcgid: ap_pass_brigade failed in handle_request function”
I don’t know what else to look into or how to get more log info.
Thank you