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: Final Working Solution for FastCGI on Apache on Windows
Author
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Thu 23 Oct '14 7:36    Post subject: Final Working Solution for FastCGI on Apache on Windows Reply with quote

After I stopped working with Apache and moved on to Linux and Nginx, I have accidentally came across of a reliable working solution for deploying FastCGI, Apache, PHP, on Windows. This solution is using mod_cgi but the release notes say FastCGI Question. Whatever it is the result is very good and reliable and it outperforms anything that I have tried on windows including mod_fastcgi and mod_fcgid. This solution performs better than Nginx on windows (I'm referring to serving php files only).

https://bitnami.com/stack/wapp/installer
WAPP Stack 5.3.29-0

This particular installer performed best in my tests and produced 0 failed requests
Other versions of WAPP installer were 10 to 20% faster but produced failed requests.

Here are test results. (See previous results in this thread for comparison: http://www.apachelounge.com/viewtopic.php?t=5789).


Test using mod_cgi Apache 2.4.10 php 5.3.29 ts
File: phpifo.php
Processes auto spawned by Apache
Time taken for tests: 3.31 sec.
Completed requests: 10000
Failed requests: 0
Requests per second: 3021



This is good enough solution for high traffic production website particularly if used with two or more web servers and a load balancer.

Additional performance improvement can be achieved by tuning windows tcp/ip stack and WIN-MPM.
Back to top
wm003



Joined: 24 Mar 2006
Posts: 88

PostPosted: Thu 23 Oct '14 12:21    Post subject: Reply with quote

mmh, i tried it but php is just running via mod_php there.

So no mod_cgi is used for running php thus this wamp does not seem any special new configuration to me.
Back to top
James Blond
Moderator


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

PostPosted: Thu 23 Oct '14 14:31    Post subject: Reply with quote

Can you please post the PHP config at https://paste.apache.org/ ?
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Thu 23 Oct '14 15:26    Post subject: Reply with quote

wm003 wrote:
mmh, i tried it but php is just running via mod_php there.


I will post the full config when I find a moment but in short here is what I did.

In httpd.comf make sure that the line is uncommented:
LoadModule cgi_module modules/mod_cgi.so

In httpd.comf comment out or remove these lines:
# LoadModule php5_module "E:/Serve /php/php5apache2_2.dll"

AddType application/x-httpd-php .php

In httpd.comf add php handler
AddHandler cgi-script .cgi .php

Configure the directory from which you want to run cgi files and move phpnfo.php to this directory.
Back to top
C0nw0nk



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

PostPosted: Thu 23 Oct '14 15:34    Post subject: Reply with quote

I thought you was using Nginx and PHP on windows now ?

I had to drop apache and use Nginx + PHP for this same reason the fcgi wrapper could not keep up with requests and i was stuck with a concurrent connection limit, But i keep a eye on apache and i use these builds here for the htpassword generator.
Back to top
gijs



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

PostPosted: Thu 23 Oct '14 15:59    Post subject: Reply with quote

are you using mod_cgi in combination with mod_php? Shocked

Doesn't that mean that we have to use thread safe PHP?
Back to top
James Blond
Moderator


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

PostPosted: Thu 23 Oct '14 16:11    Post subject: Reply with quote

I wonder why plain cgi beats f(ast)cgi(d) since with cgi the process dies after every request. Any clue?

@gijs: Nope, the module is out commented.
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Thu 23 Oct '14 17:53    Post subject: Reply with quote

C0nw0nk wrote:
I thought you was using Nginx and PHP on windows now ?

I'm using Nginx and php on Linux but I had to do a job for a client who wants windows that's why I used Apache.
Since you have mentioned Nginx on windows, there is a new branch of Win Nginx that supports running multiple
workers on windows http://nginx-win.ecsds.eu/ .

James Blond wrote:
I wonder why plain cgi beats f(ast)cgi(d) since with cgi the process dies after every request. Any clue?

I'm looking at my server and found leftovers of a previous mod_fastcgi installation that haven't been properly uninstalled. This makes me think that maybe I spoke too soon (like the inventors of cold fusion http://en.wikipedia.org/wiki/Cold_fusion Smile ) I see about 40 php-cgi processes running but now I'm not sure if they come from the new config or are a leftovers from the old config. I will dig in it when I have time and let you know but the application runs great whether by accident or by design.

Deploying anything on the fricking windows makes my dog get unnecessary beating ...... just kidding...... this is not my dog.
Back to top
C0nw0nk



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

PostPosted: Thu 23 Oct '14 19:03    Post subject: Reply with quote

Yeah jimski thats the nginx builds i use with the PHP setup supplied there too.

Everytime nginx starts logging php request time outs i just create / add more php workers and it solves the problem currently i have 100.

But if i was to dedicate a machine to it i could easly have 1000 or more.

It did solve all my problems with apache php and limits.

And yes i do use it in a extremely heavy traffic enviorment. Top 20,000 sites in the world (Porn)

I will also have a storage capacity soon of 1/4 of a petabyte in total from all the servers. So for a very large scale enviorment it is why i had to drop apache.
Back to top
jimski



Joined: 18 Jan 2014
Posts: 196
Location: USSA

PostPosted: Fri 24 Oct '14 11:00    Post subject: Reply with quote

.
1/4 of a petabyte that's a lot of data. I assume video storage consumes most of it.

Did you ever switch to Postgres or are you still using MySQL ?
Back to top
C0nw0nk



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

PostPosted: Mon 27 Oct '14 4:06    Post subject: Reply with quote

I still use MySQL but i have a single machine dedicated to it. And i use InnoDB not MyISAM. Converting images into multi scale formats (Mobile devices and different screen sizes.) And Converting videos into 360p, 480p, 720p and 1080p.

And with multiple storage machines you have to assign each storage machine to its own subdomain and deal with allot of load balancers.

The guy who made that custom Nginx build on windows also has a similar enviorment but i map my hard drives together he just proxies to them.

http://forum.nginx.org/read.php?2,254012,254103#msg-254103

Quote:
As for storage, here we use a Debian VM as storage concentrator, nginx talks to Debian on IP level and Debian manages/caches all kinds of storage units as one pool.
(mapping a drive is slow, use direct ip access)


I have thought about maybe setting up for 4k/2k, 4320p and 2160p videos too but right now it is not worth it perhaps when i reach a stage like youtube and i let people upload videos of a scale of 128GB

Currently i allow 2GB uploads but i could scale upto more since i have the ram and I/O for it.

I do how ever host some videos that are over 10 hours long. And the best HTML5 format to be using is Webm not MP4 since Webm is smaller and higher quality. But currently i have to use Mp4 and Webm since Windows XP and Vista users and Linux are not all compatible with the same formats. So you have to have both or else users cant watch videos.

http://en.wikipedia.org/wiki/HTML5_video#Browser_support

But like i said for a High Traffic enviorment you have to consider dropping apache unless you are going to try and load balance with it because there is no way with all its current limits and CPU, Ram and I/O consumption compared to Nginx that you will ever be able to reach a large high traffic scale.

(I learnt that fast hand.) But i stick around with apache here because the builds come with usefull tools.

Depending on what you are hosting will depend how resource extensive your enviorment will be.

Here is one of the largest hosting enviorments on the web but keep in mind they are Linux based. (I do it with windows.)

http://www.extremetech.com/computing/123929-just-how-big-are-porn-sites/2

I recon you could load balance to multiple machines for apache on windows but you will always hit a php or a concurrent connection limit on apache with windows unless you go to nginx.

So you would have to setup apache on multiple machines and then redirect traffic / proxy to them all it will be a bit of a complicated setup. But thats the only way i could think of you ever achieving such a high amount of traffic with Windows Apache builds.

Here is a example of my setup you can do the same with apache you would have to mount your storage / apache block on a mapped hard drive Z:/ drive for example. The load balencer will redirect you to one of your servers but all your servers will have / share the same data thats why you put all data on the mapped hard drive Z:/ (Storage server).



I hope it helps you figure out and solve your high traffic issues for me to figure this out was a night mare took a while but finally got there.
Back to top
C0nw0nk



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

PostPosted: Tue 28 Oct '14 12:36    Post subject: Reply with quote

Also on your test machine what settings are you benchmarking with ?

Code:
ab.exe -kc 1000 -n 10000 http://localhost/index.php


I will setup my Nginx and 1000 php processes on one of my dev servers to see what one single machine can output at max before load balencing.

I will do 2 different tests one with MySQL and one without just with phpinfo.

I recon it will be allot.
Back to top


Reply to topic   Topic: Final Working Solution for FastCGI on Apache on Windows View previous topic :: View next topic
Post new topic   Forum Index -> Third-party Modules