虚位以待(AD)
虚位以待(AD)
首页 > 操作系统 > Windows系列 > Windows下Zend Server VS Nginx VS Lighttpd PHP运行测试

Windows下Zend Server VS Nginx VS Lighttpd PHP运行测试
类别:Windows系列   作者:码皇   来源:互联网   点击:

虽说,在Windwos测试看起来毫无价值,但是这件事对于我自身,和我公司目前的一些事情和状况来说,还是有价值的。所以我会坚持测试完毕。今天下午会在同一台机器上(换硬盘),装Ubuntu Server,然后装Zend Ser

虽说,在Windwos测试看起来毫无价值,但是这件事对于我自身,和我公司目前的一些事情和状况来说,还是有价值的。所以我会坚持测试完毕。

今天下午会在同一台机器上(换硬盘),装Ubuntu Server,然后装Zend Server、Nginx、Lighttpd,然后再进行同样的性能测试比较。

还是昨天的机器,进行三种不同的脚本测试:

info.php,测试重点,php枚举自身的php环境的数据。

 
1
<?php
2
# info.php
3
phpinfo();
db.php,打开mysql数据库,测试连接数据库的性能,使用PDO,并且抽取10条记录,Post表现村145篇文章
 
01
<?php
02
/* Connect to an ODBC database using driver invocation */
03
$dsn = 'mysql:dbname=wp_demo;host=192.168.33.2';
04
$user = 'root';
05
$password = 'mysql50';
06
 
07
try {
08
    $dbh = new PDO($dsn, $user, $password);
09
    foreach ($dbh->query("select * FROM wp_posts limit 10, 10") as $row) {
10
        echo $row['post_title'] , '<br />';
11
    }
12
} catch (PDOException $e) {
13
    echo 'Connection failed: ' . $e->getMessage();
14
}
open.php,测试经过PHP来处理IO的性能,sina.txt文件大小593kb。
 
1
<?php
2
 
3
echo file_get_contents('sina.txt');
4
exit();
nginx和lighttpd仍旧使用昨天测试时的配置,php-cgi,默认启动10个进程,Windows环境,为了某些因素,没有用我自己写的监护进程,在网上找到一个叫做xxfpm的东西,http://xiaoxia.org/2011/02/01/xxfpm-wrote-a-fastcgi-process-manager/,这个东西类似php-fpm,可以监控php-cgi进程,无论你怎么杀php-cgi进程,都杀不死,除非将xxfpm给杀了。

启动后的情况。

Nginx和Lighttpd,都是用fastcgi转交给该php-cgi来处理。配置就不列举了。

而Zend Server部分,比如我的安装在C:Zend,C:ZendZendServeretcZendEnablerConf.xml。调整通过ZendServer启动的php-cgi进程,需要如下的配置:


01
<?xml version="1.0" encoding="UTF-8"?>
02
<ZendEnablerConfiguration version="2.0"
03
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
04
    xsi:noNamespaceSchemaLocation="ZendEnablerConf.xsd">
05
    <Global>
06
        <LogFile path="C:ZendZendServerlogsZendEnabler.log" verbosity="0"maxFileSizeKB="100" />    
07
    </Global>
08
    <DefaultPool impersonation="true">
09
        <Environment>
10
            <Variable name="DB2INSTANCE" value="DB2" />
11
            <Variable name="PHP_FCGI_MAX_REQUESTS" value="10000" />
12
            <Variable name="TEMP" value="C:DOCUME~1JanLOCALS~1Temp" />
13
            <Variable name="PHPRC" value="C:ZendZendServeretc" />
14
            <Variable name="PATH" value="C:Program FilesNVIDIA CorporationPhysXCommon;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:Program FilesTortoiseSVNbin;C:Program FilesQuickTimeQTSystem;C:scalasbt.11;C:qtjambi4.7.1;C:qtjambi4.7.1bin';C:Program FilesStormIICodec;C:Program FilesStormII;C:scalabin;E:Program FilesThunder NetworkThunderProgram;C:ZendZendServerbin" />
15
        </Environment>
16
        <ProcessCount start="10" extra="10"/>
17
        <Timeouts connectionTimeout="60" requestTimeout="120" />
18
    </DefaultPool>
19
    <ServerPool mimeType="application/x-httpd-php"commandLine="C:ZendZendServerbinphp-cgi.exe" impersonation="true">
20
        <ProcessCount start="10" extra="10"/>
21
    </ServerPool>
22
</ZendEnablerConfiguration>

 


以下是测试结果(数值为rps的结果):

Nginx
-t 10
info.php db.php open.php
72.64 90.95 12.63
70.2 88.13 12.67
73.53 94.15 13.79
-c 100 -n 1000
info.php db.php open.php
158.93 584.16 18.62
158.15 609.88 18.67
157.62 606.06 18.28
     
Lighttpd
-t 10
info.php db.php open.php
26.68 86.38 16.88
31.52 90.39 17.09
26.48 91.51 16.97
-c 100 -n 1000
info.php db.php open.php
138.73 518.18 19.48
145.64 470.17 19.42
140.42 602.75 19.5
     
Zend Server
-t 10
info.php db.php open.php
74.68 98.36 17.51
69.66 101.25 17.37
75.77 105.85 17.01
-c 100 -n 1000
info.php db.php open.php
133.15 1029.77 19.48
134.66 1035.74 19.49
133.43 1040.52 19.45

 

显然,Zend Server是Windows平台下的优胜者,尤其是在db.php的表现上。而Nginx和Lighttpd对比上,可看得出,Nginx的稳定性较好,处理PHP是适合的选择,而Lighttpd在IO方面,则较为出色(open.php)。

好,Windwos的平台告一段落,下午会重新装一个Ubuntu Server,重复进行上述的测试。为了公正起见,不会进行过分的优化调整,而是简单的测试10进程php-cgi模式。尽量先完成默认配置的测试以后,再进行优化配置,而后再来比较。

另外,同事说Windows下的cherokee也十分猛,强烈要求进行测试,该测试会在完成Linux测试以后进行。

另外的另外,我还希望能测试IIS 7.5 fastcgi的情况,但是因为这个电脑默认装的是xp,要转win7测试。我的笔记本虽然是win7,但是因为硬件条件不同,全部的测试要重新进行一次。这个会放到最后进行



摘自 曾建凯的博客
相关热词搜索: Windows Zend Server