nginx with PHP - windows performance

jack_ nginx-forum at nginx.us
Fri Jun 3 15:39:53 MSD 2011


After 2 days of testing I'm able to run nginx on Windows Vista x64 SP2
with PHP
I'm using a Kevin Worthington 1.04 cygwin build with 2 worker processes
and 5 child's of php-cgi.exe
On a hardware like Laptop with Intel Core2Duo P8400 2.26GHz with 3GB of
RAM and 250GB 7200 1/min HDD
I've been able to receive results like below:

nginx + PHP
[Tested locally with Apache Benche - using: ab.exe -n 5000 -c 1000
127.0.0.1/
The file reached is index.php with code only <?php phpinfo(); ?>]

nginx + php 5.3.6 x86 build thread-safe -> 199 requests / sec
nginx + php 5.3.6 x86 build NON thread-safe -> 208 requests / sec
nginx + php 5.3.6 x64 build thread-safe -> 176 requests / sec
nginx + php 5.3.6 x64 build NON thread-safe -> 185 requests / sec

nginx + HTML
[Tested locally with Apache Benche - using: ab.exe -n 5000 -c 1000
127.0.0.1/
The file reached is index.html created by Kevin Worthington]

nginx with multi_accept off -> 445 requests / sec
nginx with multi_accept on -> 900 requests / sec

Level of failed requests never was higher than 5 requests.

My nginx.conf
#user  nobody;
worker_processes  2;

#error_log  logs/error.log debug;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  error;

pid        logs/nginx.pid;


events {
    worker_connections  2048;
	
	# multi_accept gives wings but only with HTML - not PHP!!!
	multi_accept off;
	accept_mutex  on;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local]
"$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

	access_log  off;
    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

	# Enable only on CYGWIN nginx build !!
	ssl_session_cache    shared:SSL:10m;
    ssl_session_timeout  5m;
	
    keepalive_timeout  30;

	gzip             on;
	gzip_min_length  1000;
	gzip_proxied     expired no-cache no-store private auth;
	gzip_types       text/plain application/xml;
	gzip_disable     "MSIE [1-6]\.";

	# Settings for multiple php-cgi.exe
	#
	upstream backend {
		server   127.0.0.1:9000;
		server   127.0.0.1:9001;
		server   127.0.0.1:9002;
		server   127.0.0.1:9003;
		server   127.0.0.1:9004;
	}
	
    server {
        listen       80;
		listen       443 ssl;
        server_name  www.sklep.beta.ostrowwlkp.pl;
		ssl_certificate server.crt;
		ssl_certificate_key server.key;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.php;
        }

		# Statyczne elementy mogą być cache'owane przez przeglądarkę przez
określoną ilość dni [lub max]
		#
		#location ~* \.(ico|css|js|gif|jpe?g|png)$ {
		#	expires 30d;
		#}

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # pass the PHP scripts to FastCGI server listening on
127.0.0.1:9000
        #
        location ~ \.php$ {
            root           html;
			fastcgi_pass backend;
			#fastcgi_pass 127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME 
c:/nginx/html/$fastcgi_script_name;
            include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
}



Any proposition for improvement ???
Enabling multi_accept on; with PHP pages is crashing connection.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,203283,203283#msg-203283




More information about the nginx mailing list