测试环境:Windows 2003 Apache2.2(VC9) PHP 5.3(VC9 Non Thread Safe)
测试参数:ab -c 10 -t 10 http://adress

性能测试:静态HTML

测试结果:

Concurrency Level:      10
Time taken for tests:   10.000 seconds
Complete requests:      6554
Failed requests:        0
Write errors:           0
Total transferred:      2157253 bytes
HTML transferred:       288508 bytes
Requests per second:    655.40 [#/sec] (mean)
Time per request:       15.258 [ms] (mean)
Time per request:       1.526 [ms] (mean, across all concurrent requests)
Transfer rate:          210.67 [Kbytes/sec] received

性能测试:CIG方式

配置:

<directory>
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</directory>

ScriptAlias /php5/ "E:/Servers/Php5.3/"
Action application/x-httpd-fastphp5 "/php5/php-cgi.exe"
AddType application/x-httpd-fastphp5 .php

测试结果:

Concurrency Level:      10
Time taken for tests:   10.016 seconds
Complete requests:      167
Failed requests:        0
Write errors:           0
Total transferred:      9958014 bytes
HTML transferred:       9931338 bytes
Requests per second:    16.67 [#/sec] (mean)
Time per request:       599.738 [ms] (mean)
Time per request:       59.974 [ms] (mean, across all concurrent requests)
Transfer rate:          970.95 [Kbytes/sec] received

性能测试:fcgid方式

配置:

LoadModule fcgid_module modules/mod_fcgid.so

    AddHandler fcgid-script .fcgi .php
    #php.ini的存放目录
    FcgidInitialEnv PHPRC "e:/Servers/Apache-confs/"
    # 设置PHP_FCGI_MAX_REQUESTS大于或等于FcgidMaxRequestsPerProcess,防止php-cgi进程在处理完所有请求前退出
    FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 500
    #php-cgi每个进程的最大请求数
    FcgidMaxRequestsPerProcess 500
    #php-cgi最大的进程数
    FcgidMaxProcesses 5
    #最大执行时间
    FcgidIOTimeout 120
    FcgidIdleTimeout 120
    #php-cgi的路径
    FcgidWrapper "e:/Servers/Php5.3/php-cgi.exe" .php
    AddType application/x-httpd-php .php

	Options Indexes FollowSymLinks ExecCGI
	Order allow,deny
	Allow from all
	AllowOverride All

测试结果:

Concurrency Level:      10
Time taken for tests:   10.016 seconds
Complete requests:      375
Failed requests:        336
   (Connect: 0, Receive: 0, Length: 336, Exceptions: 0)
Write errors:           0
Total transferred:      20406982 bytes
HTML transferred:       20340934 bytes
Requests per second:    37.44 [#/sec] (mean)
Time per request:       267.083 [ms] (mean)
Time per request:       26.708 [ms] (mean, across all concurrent requests)
Transfer rate:          1989.76 [Kbytes/sec] received

结论

可以看到fcgid方式对比CGI方式,完成请求数位160:370,平均相应时间:599ms:267ms

有关PHP优化:http://www.vpser.net/opt/apc-eaccelerator-xcache.html
http://www.woniu.us/php_basic/123.html

目前使用的版本组合:
Apache 2.2 VC9
PHP 5.3.6 nts vc9
mod_fcgid-2.3.6-win32-x86
XCache-1.3.0-php-5.3.0-nts-Win32-VC9-x86.zip
VC 2008 RunTime vcredist_x86

(171)


发表评论

电子邮件地址不会被公开。