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 -> Third-party Modules View previous topic :: View next topic
Reply to topic   Topic: mod_fastcgi better than mod_fcgid !?! Page Previous  1, 2, 3, 4, 5  Next
Author
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Sat 08 Feb '14 19:53    Post subject: Reply with quote

That binary you have is SNAP-0910052141 sort of. It's weird in that the actual snap's changes are just 1 change shy of that module. The one extra change in that binary you have is;

*) Update to compile against httpd-2.4.3. [Peter Danenberg]

yet at the top of the changes file that module was built with it says mod_fastcgi-SNAP-0910052141.

Anyhow, that tells me the SNAP-0910052141 and earlier probably will not compile against Apache 2.4 so I doubt anyone is going to compile them for you.
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Sun 09 Feb '14 2:12    Post subject: Reply with quote

glsmith wrote:
That binary you have is SNAP-0910052141 sort of.

I'm looking for precompiled binaries for Apache 2.2
(Win32) mod_fastcgi-SNAP-0811090952 binary
(Win32) mod_fastcgi-SNAP-0910052141 binary
If you have them please post the a link. Thank you.
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Sun 09 Feb '14 2:33    Post subject: Reply with quote

This will surprise you
After downgrading from php 5.4.24 to php 5.3.8
All the failed requests under mod_FCGID went away but the overall performance degraded. I used the same php.ini settings

Here are the latest results.

Test file phpinfo.php
Test using mod_FCGID Apache 2.4 php 5.3.8 ts
10 processes
Time taken for tests: 13.1 sec.
Completed requests: 10000
Failed requests: 0
Requests per second: 768

Test using mod_FCGID Apache 2.4 php 5.3.8 nts
10 processes
Time taken for tests: 9.1 sec.
Completed requests: 10000
Failed requests: 0
Requests per second: 1109

Test using mod_FastCGI Apache 2.4 php 5.3.8 nts
10 processes
Time taken for tests: 3.35 sec.
Completed requests: 10000
Failed requests: 1099
Requests per second: 2976

Although mod_FastCGI stalls and generates failed requests it is clearly superior when it comes to speed of processing concurrent requests. Unfortunately is not usable for production.

The premature exiting of php-cgi.exe processes seem to be related to a limit set at compilation stage and so far I couldn't find directive to override it. Looks like each process last about 500 requests and then exits. If this issue is fixed this will be one hell of solution for php on windows which will beat the pants off of FCGID.


Last edited by jimski on Sun 09 Feb '14 21:26; edited 2 times in total
Back to top
Steffen
Moderator


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

PostPosted: Sun 09 Feb '14 9:29    Post subject: Reply with quote

PHP recycles native php-cgi processes after 500 requests.

See under the heading Special PHP considerations at http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html

Steffen
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Sun 09 Feb '14 12:51    Post subject: Reply with quote

jimski wrote:

I'm looking for precompiled binaries for Apache 2.2


You did not specify 2.2 earlier, anyhow, VC9 compiled against ApacheHaus' 2.2.26. Modules are in the Release folders.

Moderator Edit: Remove stale link


Last edited by glsmith on Fri 02 Jan '15 3:49; edited 2 times in total
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Sun 09 Feb '14 20:01    Post subject: Reply with quote

'
Steffen wrote:
PHP recycles native php-cgi processes after 500 requests.

See under the heading Special PHP considerations at http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html

Steffen

Steffen, if this is the case then how do you override 500 requests limit with mod_fastcgi on windows.
There is no FCGI_MAX_REQUESTS directive, or anything similar, in the specifications for mod_FastCGI http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html.

The mod_FastCGI supposed to keep the process alive by default and only destroy it as needed using -killInterval or other process control directive.

Here is what Lighty writes about it:
FastCGI removes this limitation by keeping the process running and handling the requests by this always running process. This removes the time used for the fork() and the overall startup and cleanup time which is necessary to create and destroy a process. http://redmine.lighttpd.net/projects/1/wiki/Docs_ModFastCGI


glsmith wrote:

You did not specify 2.2 earlier, anyhow, VC9 compiled against ApacheHaus' 2.2.26. Modules are in the Release folders.

Thank you glsmith, I will give it a spin and if it works I will post results.

Moderator Edit: Remove stale link
Back to top
CamaroSS



Joined: 24 Jan 2013
Posts: 78
Location: RF, Tver

PostPosted: Mon 10 Feb '14 12:55    Post subject: Reply with quote

Quote:

Steffen, if this is the case then how do you override 500 requests limit with mod_fastcgi on windows.
There is no FCGI_MAX_REQUESTS directive, or anything similar, in the specifications for mod_FastCGI http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html.

I think
Code:
FastCgiServer -initial-env PHP_FCGI_MAX_REQUESTS=0

should fix it. It's just another environment variable.
Back to top
Steffen
Moderator


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

PostPosted: Mon 10 Feb '14 13:45    Post subject: Reply with quote

Also advised to set env: FcgidInitialEnv PHP_FCGI_CHILDREN 0

For mod_fcgid from the docu:

PHP child process management (PHP_FCGI_CHILDREN) should always be disabled with mod_fcgid, which will only route one request at a time to application processes it has spawned; thus, any child processes created by PHP will not be used effectively. (Additionally, the PHP child processes may not be terminated properly.) By default, and with the environment variable setting PHP_FCGI_CHILDREN=0, PHP child process management is disabled.
Back to top
CamaroSS



Joined: 24 Jan 2013
Posts: 78
Location: RF, Tver

PostPosted: Mon 10 Feb '14 14:55    Post subject: Reply with quote

I don't get it. The last time I've checked, PHP for Windows couldn't fork and therefore couldn't have child processes, so this variable has no effect. Additionally, a single php-fcgi process couldn't handle more than one request at a time. Did anything change?
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Mon 10 Feb '14 17:03    Post subject: Reply with quote

Thank you CamaroSS and Steffen I will try it.

CamaroSS wrote:
I don't get it. The last time I've checked, PHP for Windows couldn't fork and therefore couldn't have child processes, so this variable has no effect. Additionally, a single php-fcgi process couldn't handle more than one request at a time. Did anything change?

Windows server versions can fork with Interix subsystem which is build in by default in windows server 2003R2 and 2008 http://en.wikipedia.org/wiki/Interix . But CamarroSS is right that forking is not used by php for windows. There is however a fastcgi.dll that should spawn a new thread for each requests (at least that's what I've been told)

Here is cryptic and convoluted tutorial about how to use this dll http://forum.lazarus.freepascal.org/index.php?topic=13312.0
Using mod_FastCGI on windows is definitely poorly documented and not easy to figure out.
Back to top
C0nw0nk



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

PostPosted: Mon 10 Feb '14 19:53    Post subject: Reply with quote

CamaroSS wrote:

Code:
FastCgiServer -initial-env PHP_FCGI_MAX_REQUESTS=0

should fix it. It's just another environment variable.



Does that actualy work if you already have this set ?

Code:
FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 0
FcgidInitialEnv PHP_FCGI_CHILDREN 0


Or do they both do seperate things ?
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Mon 10 Feb '14 20:13    Post subject: Reply with quote

C0nw0nk wrote:

Does that actualy work if you already have this set ?
Or do they both do seperate things ?


CamaroSS was referring to mod_fastcgi and you are using mod_fcgid, they have different directives and CamaroSS suggestion will not work with mod_fcgid.
Meanwhile Steffen was referring to mod_fcgid while I was asking about mod_fastcgi.
We have some miscommunication going on here. Wink
Back to top
C0nw0nk



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

PostPosted: Mon 10 Feb '14 20:47    Post subject: Reply with quote

According to apache it would ? http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html#examples

They use this in there ?
Code:
FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 0
FcgidInitialEnv PHP_FCGI_CHILDREN 0
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Tue 11 Feb '14 8:59    Post subject: Reply with quote

New status on mod_FastCGI
The suggestion of CamaroSS worked and the processes are not dying anymore. However the errors still persist with phpinfo.php although at much lower rate.

Here are the latest tests performed on Windows Server 2003R2 x64
Test file phpinfo.php
Test using mod_FastCGI Apache 2.4.4 x64 php 5.3.22 x64 nts
10 processes
Time taken for tests: 3.61 sec.
Completed requests: 10000
Failed requests: 996
Requests per second: 2759

Randomly this error appears when pointing firefox to localhost/phpinfo.php The entire phpinfo page is being displayed but the browser says "waiting for localhost" and after 30 seconds this appears in the error log.

FastCGI: comm with server "C:/Server/Apache24/www/php-cgi.exe" aborted: idle timeout (30 sec), referer: http://localhost/phpinfo.php
FastCGI: incomplete headers (0 bytes) received from server "E:/Server/Apache24/www/php-cgi.exe", referer: http://localhost/phpinfo.php


Last edited by jimski on Tue 11 Feb '14 11:58; edited 1 time in total
Back to top
James Blond
Moderator


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

PostPosted: Tue 11 Feb '14 11:51    Post subject: Reply with quote

can you please try to adjust the values for mod_fcgid

Code:

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


Give it a shot of love <3

-- edit 1 --
for mod_fcgid


Last edited by James Blond on Tue 11 Feb '14 12:30; edited 1 time in total
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Tue 11 Feb '14 11:55    Post subject: Reply with quote

James, My apologies for the typo. I meant mod_FastCGI and not mod_FCGID.

If you could kindly adjust your post to comment on FastCGI it would be great.

I thought that errors may be related to a buffer and I added -flush directive to send unbuffered data but this didn't fix the errors.
I also increased memory in php but also with no result.

I don't see a directive to adjust the buffer sidze in FastCGI docs.


Last edited by jimski on Tue 11 Feb '14 12:38; edited 1 time in total
Back to top
James Blond
Moderator


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

PostPosted: Tue 11 Feb '14 12:38    Post subject: Reply with quote

For the fastcgi timeout you may try to use

-appConnTimeout

found at http://www.fastcgi.com/drupal/node/25 which seems to be a bit of documentation.


--- edit ---
also maybe

http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Tue 11 Feb '14 12:42    Post subject: Reply with quote

I have -appConnTimeout set to 30 seconds that's why the error is reported after 30 seconds. This is plenty of time to execute almost any script.

Here are my latest settings:

Code:
FastCgiConfig -initial-env PATH  -idle-timeout 400 -killInterval 3600 -maxClassProcesses 10 -maxProcesses 10 -startDelay 1 -minProcesses 10
FastCgiServer "C:/Server/Apache24/www/php-cgi.exe" -initial-env PATH -initial-env PHP_FCGI_MAX_REQUESTS=0 -initial-env PHP_FCGI_CHILDREN=0 -appConnTimeout 30 -processes 10  -init-start-delay 1 -restart-delay 1 -min-server-life 6000 -listen-queue-depth 10000 -flush


Last edited by jimski on Tue 11 Feb '14 15:45; edited 3 times in total
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Tue 11 Feb '14 13:09    Post subject: Reply with quote

I think we are getting closer to finding the problem.

1. If I specify -processes 1 , then there is 0 Failed Requests

2. If I specify -processes 3, then there is 33% failed requests

3. If I specify -processes 10, then there is 10% failed requests

4. If I specify -processes 100 , then there is 1% failed requests

5. After the server is shut down there is always one orphan zombie php-cgi process lingering around that I have to shut down manually.

So the problem is that if more than one process is running then out of all the running processes there is always one which is dead and it is causing failed requests at a rate described by this equation:
failed_requests = total_requests * (1 / number_of_processes )


The more processes are running, the lower the error rate.


Last edited by jimski on Tue 11 Feb '14 19:51; edited 2 times in total
Back to top
James Blond
Moderator


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

PostPosted: Tue 11 Feb '14 15:40    Post subject: Reply with quote

Do I get it right that if you define -processes 1 you have one single instance of php-cgi.exe running in your task manager?

What does happen if that instances crashes? Does fastcgi start a new one? Do requests fail it that case?
Back to top


Reply to topic   Topic: mod_fastcgi better than mod_fcgid !?! View previous topic :: View next topic
Post new topic   Forum Index -> Third-party Modules Page Previous  1, 2, 3, 4, 5  Next