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 1, 2, 3, 4, 5  Next
Author
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Thu 06 Feb '14 1:50    Post subject: mod_fastcgi better than mod_fcgid !?! Reply with quote

I'm proposing a new discussion about mod_fastcgi because mod_fastcgi can accept multiple concurrent requests per process while mod_fcgid can't.

There is new binary for windows at https://www.apachehaus.net/modules/mod_fastcgi/

Mod_fastcgi can work with apache on windows and Microsoft selected mod_fastcgi after working closely with guys from php to give IIS competing edge.


Last edited by jimski on Thu 06 Feb '14 20:23; edited 1 time in total
Back to top
Smitty



Joined: 03 Jan 2008
Posts: 197

PostPosted: Thu 06 Feb '14 3:37    Post subject: Reply with quote

Does it work correctly with the opcache extension enabled?

Can you post the recommended configuration for php.ini?
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Thu 06 Feb '14 3:54    Post subject: Reply with quote

I got it to work as apache module however I'm new to fastcgi myself so my setup is not recommended because is not fully debugged but I will post it tomorrow and maybe we can find a way to fix it.

I'm not sure how it will work with opcache.
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Thu 06 Feb '14 12:49    Post subject: Reply with quote

Here is my setup which works but has a few glitches. The problem I have is that each php-cgi.exe processes exits after about 500 requests and then a new one is spawned again. This causes delays and failed requests while the new process is being spawn.

1. Set your environment path to point to php and apache bin folders
2. Copy the php-cgi.exe to the ScriptAlias Location that you specify below, in this case it is /Apache24/www
3. Add to httpd.conf the following

LoadModule fastcgi_module modules/mod_fastcgi.so

<IfModule mod_fastcgi.c>
ScriptAlias /www/ "C:/Server/Apache24/www/"
FastCgiConfig -initial-env PATH -autoUpdate -idle-timeout 120 -killInterval 3600 -maxClassProcesses 10 -maxProcesses 10 -startDelay 2
FastCgiServer "C:/Server/Apache24/www/php-cgi.exe" -initial-env PATH -processes 1

AddType application/x-httpd-php .php

<Files ~ "\.(php)$">
Options FollowSymLinks ExecCGI
AddHandler php-fastcgi .fcgi .php
</Files>

<Location /www/>
Options ExecCGI
SetHandler php-fastcgi
</Location>

Action php-fastcgi "/www/php-cgi.exe"

</IfModule>


I don't have anything added to my php.ini and I think this may be part of the problem


Last edited by jimski on Mon 10 Feb '14 8:57; edited 2 times in total
Back to top
gijs



Joined: 27 Apr 2012
Posts: 189
Location: The Netherlands

PostPosted: Thu 06 Feb '14 18:34    Post subject: Reply with quote

Sounds interesting, I would try it out but I don't want failed requests since that would result in people would leaving my website...
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Thu 06 Feb '14 20:06    Post subject: Reply with quote

gijs wrote:
I don't want failed requests since that would result in people would leaving my website...

This thread was started to so we can figure out the best way to run this module. Please post back your experiences.
Back to top
Millennium



Joined: 17 Apr 2006
Posts: 179
Location: Leiderdorp, NL, EU

PostPosted: Thu 06 Feb '14 21:42    Post subject: Reply with quote

Why make another topic about mod_fcgi? Now there are reactions in both, some admin should merge them.
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Thu 06 Feb '14 22:49    Post subject: Reply with quote

TESTING METHODOLOGY for FASTCGI vs FCGID

When using the Fastcgi and Fcgid modules please use this testing method so we have somehow comparable results.
Many of you will be surprised how many failed requests you will get using your mod_Fcgid which you thought was running well.

FIRST test for FCGID

1. Disable any Caching in php disable opcache, APC, eAccellerator etc. and in Apache disable mod_cache.

2. Use this php file. Copy the line below and save it as phpinfo.php. It is just one line but gives apache and php good beating.

<?php phpinfo(); ?>

3. Set FcgidMaxProcesses 1
FcgidMaxProcessesPerClass 1
FcgidProcessLifeTime 0
FcgidMaxRequestsPerProcess 0


4. Run Apache Bench with these parameters and save results
ab -n 10000 -c 1 http://127.0.0.1:80/phpinfo.php

5. Then set FcgidMaxProcesses 10
FcgidMaxProcessesPerClass 10
FcgidMinProcessesPerClass 10


6. Restart Apache

7. Run Apache Bench with these parameters just to spawn the processes but ignore the results
ab -n 10000 -c 100 http://127.0.0.1:80/phpinfo.php

8. Run Apache Bench again with these parameters and save your results
ab -n 10000 -c 100 http://127.0.0.1:80/phpinfo.php

9. Post your results using these 4 lines only:
Time taken for tests: xxx
Complete requests: xxx
Failed requests: xxx
Requests per second: xxx




SECOND test for FASTCGI

1. Disable any Caching in php disable opcache, APC, eAccellerator etc. and in Apache disable mod_cache.

2. Use this php file.
<?php phpinfo(); ?>

3. First set -processes to 1 in FastCgiServer "C:/Server/Apache24/www/php-cgi.exe" -initial-env PATH -processes 1

4. Run Apache Bench with these parameters and save your results
ab -n 10000 -c 1 http://127.0.0.1:80/phpinfo.php

5. Then set -processes to 10 in FastCgiServer "C:/Server/Apache24/www/php-cgi.exe" -initial-env PATH -processes 10

6. Restart Apache

7. Wait 30 seconds or so to allow all processes to spawn (you may want to monitor the taskmanager to make sure all processes are up

8. Run Apache Bench with these parameters
ab -n 10000 -c 100 http://127.0.0.1:80/phpinfo.php

9. Post your results using those 4 lines only:
Time taken for tests: xxx
Complete requests: xxx
Failed requests: xxx
Requests per second: xxx


Any suggestions to improve this test are welcome.


Last edited by jimski on Mon 10 Feb '14 9:01; edited 9 times in total
Back to top
James Blond
Moderator


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

PostPosted: Thu 06 Feb '14 23:16    Post subject: Reply with quote

Well I think one of the adavanges I use on fcgid (aslo to use opcache) is running an instance infinit or till server restart.

Code:

   ProcessLifeTime 0
   FcgidMaxRequestsPerProcess 0
   FcgidMinProcessesPerClass 0
   FcgidProcessLifeTime 0


Last edited by James Blond on Thu 06 Feb '14 23:20; edited 1 time in total
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Thu 06 Feb '14 23:19    Post subject: Reply with quote

Thank you James, great point. I will add it to test description above. Although I think that the FcgidMinProcessesPerClass should be 10 and not 0.
This will make it comparable with 10 Fastcgi processes which should be up and waiting for requests at all times.


Last edited by jimski on Fri 07 Feb '14 0:42; edited 2 times in total
Back to top
James Blond
Moderator


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

PostPosted: Thu 06 Feb '14 23:20    Post subject: Reply with quote

Quote:

The problem I have is that each php-cgi.exe processes exits after about 400 requests and then a new one is spawned again. This causes delays and failed requests while the new process is being spawn.


Did you solve this?

With fcgid I can kill any php process and won't notice a delay in the next request.

--- edit ---

you may also take a look on http://www.apachelounge.com/viewtopic.php?t=5773

Can you run different PHP versions with fastcgi?
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Thu 06 Feb '14 23:28    Post subject: Reply with quote

James Blond wrote:

Did you solve this?


No I didn't figure it out.

On my FCGID setup I also get failed requests when running the test above.

Quote:
Can you run different PHP versions with fastcgi?

Do you mean different version in the same time let's say php5.3 and php5.4 sending requests together to the same mod_fastcgi ?


Last edited by jimski on Sun 09 Feb '14 8:25; edited 2 times in total
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Fri 07 Feb '14 13:12    Post subject: Reply with quote

My test results using dual quad core Xeon X5660 2.8ghz.

Test file phpinfo.php
Test using mod_fcgid Apache 2.4
10 processes
Time taken for tests: 9.1 sec.
Completed requests: 10000
Failed requests: 1237
Requests per second: 1109

Test using mod_fastcgi Apache 2.4
10 processes
Time taken for tests: 3.1 sec.
Completed requests: 10000
Failed requests: 3757
Requests per second: 3084

Test using mod_php Apache 2.2 Mr. Green
Time taken for tests: 3.35 sec.
Completed requests: 10000
Failed requests: 0
Requests per second: 2975


Don't ask me what's going on because I don't understand myself. Either I missconfigured everything terribly or fcgid on Windows ain't so fast. Funny thing is that I'm not alone.

The author of this article also found that mod_php on Apache is faster than fastCGI on nginx. Don't be fooled by the title, the conclusion of the article is that mod-php is faster.
http://www.eschrade.com/page/why-is-fastcgi-w-nginx-so-much-faster-than-apache-w-mod_php/


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



Joined: 17 Apr 2006
Posts: 179
Location: Leiderdorp, NL, EU

PostPosted: Fri 07 Feb '14 14:49    Post subject: Reply with quote

Lots of failed requests. Which version of php are you using? NTS or TS?
Back to top
James Blond
Moderator


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

PostPosted: Fri 07 Feb '14 15:35    Post subject: Reply with quote

jimski wrote:
James Blond wrote:

Did you solve this?


No I didn't fidure it our. Can you send me an email at [ box at ebusinessatoz.com] , I may have a small freelance Apache + FCGID job for you if you are interested.

On my FCGID setup I also get failed requests when running the test above.

Quote:
Can you run different PHP versions with fastcgi?

Do you mean different version in the same time let's say php5.3 and php5.4 sending requests together to the same mod_fastcgi ?


Yes I mean running 5.3 and 5.4 at the same time.



Please give fcgid a chance with more allowed intances. Also like Millennium I'd like to know which version you took for testing and if it was TS or NTS.
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Fri 07 Feb '14 20:43    Post subject: Reply with quote

Millennium and James
I'm using NTS version for fcgid and fastcgi.
I will switch to TS today and I will post results.

So far I see a great promise in the mod_fastcgi if we can figure out why the processes are exiting after 400 requests and are re-spawned again.

I will try some of these parameters today:
-listen-queue-depth, multiThreshold, singleThreshold

I will also dig in the Microsoft papers to see if there is anything that we could try with Apache.
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Fri 07 Feb '14 21:48    Post subject: Reply with quote

Test results using php TS.

Test file phpinfo.php
Test using mod_fcgid Apache 2.4
10 processes
Time taken for tests: 10.3 sec.
Completed requests: 10000
Failed requests: 1276
Requests per second: 9001

Test using mod_fastcgi Apache 2.4
FastCGI WON'T START AT ALL with TS.
It complains about missing php5.dll and when I try to trick it by renaming php5ts.dll to php5.dll then complains about missing SAPI entry point.



IT GETS MORE INTERESTING
When I test FCGID and FastCGI with a php file that I wrote:
<?php for ($x=0; $x<=10; $x++){ Print "Hello World"; }?>

Test file mytest.php
Test using mod_fcgid Apache 2.4 php nts
10 processes
Time taken for tests: 1.41 sec.
Completed requests: 10000
Failed requests: 0
Requests per second: 6881

Test using mod_fastcgi Apache 2.4 php nts
10 processes
FastCGI stalls randomly to respawn processes but when works the results are as follow:
Time taken for tests: 1.35 sec.
Completed requests: 10000
Failed requests: 0
Requests per second: 6921

Test using mod_php Apache 2.2 php ts
Time taken for tests: 1.1 sec. Mr. Green
Completed requests: 10000
Failed requests: 0
Requests per second: 8648
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Sat 08 Feb '14 13:31    Post subject: Reply with quote

'
Guys, can someone send me a link to these binaries

(Win32) mod_fastcgi-SNAP-0811090952 binary

(Win32) mod_fastcgi-SNAP-0910052141 binary


I can't find them anywhere on the net and I have looked far and wide.
I would like to complete the tests of FastCGI on windows against those older binaries.
Back to top
C0nw0nk



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

PostPosted: Sat 08 Feb '14 15:06    Post subject: Reply with quote

As james blond said in another post.

James Blond wrote:
Difference between mod_fastcgi and mod_fcgid is mostly at license level. Although mod_fastcgi is somewhat non-free. Also mod_fastcgi hasn't been developed since some time.

The difference between mod_php and mod_fcgid/mod_fastcgi is the technic itself. Mod_php is loaded into apache, so more or less php runs inside of the apache process. That's why the memory usage grows / can grow with the number of php requests. The f(ast)cgi(d) technic runs a separate php process outside of apache. You can see that as php-cgi.exe processes in your task manager.

How many req/s do you want to serv? What php scripts do you run that takes so much memory?


From my experience mod_fcgid is the best never had any issues handles easly over 1million requests a day and apache does crash neither does it show cpu usage high or ram consumption high.
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

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

C0nw0nk wrote:
From my experience mod_fcgid is the best never had any issues handles easly over 1million requests a day


Can you run the test described above with phpinfo.php and post your results.
'
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 1, 2, 3, 4, 5  Next