<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>https://jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>https://jackxiang.com/post//</link>
<title><![CDATA[[转贴]CGI, mod_perl, PHP, JSP性能比较Web服务器教程]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[WEB2.0]]></category>
<pubDate>Tue, 27 Apr 2010 12:51:33 +0000</pubDate> 
<guid>https://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	** 请注意! ** <br/>测试结果很大程度上依赖于机器的硬件/软件配置，并随配置变化而产生差异，因此： <br/>本测试结果 *仅供参考* <br/><br/>测试用硬件： <br/>CPU: Intel PII 300(66x4.5) <br/>RAM: 192M <br/>HD: IBM 20G(2M cache) <br/><br/>测试用软件： <br/>OS: Slackware 7(自行编译的2.2.14核心) <br/>Web: Apache 1.3.12(标准模块按缺省配置，所有模块静态编译) <br/>PHP 4.0 RC1(加入了MySQL支持) <br/>mod_perl 1.23(缺省配置，未加EVERYTHING=1) <br/>ApacheJServ 1.1(缺省配置) <br/>JDK: JDK 1.2.2 <br/>JSDK: JSDK 2 <br/>JSP: GNUJSP 1.0.0 <br/>JSP: GNUJSP 1.0.0 <br/><br/>本测试是用Apache自带的Apache Bench(ab)进行的，命令为： <br/>/www/bin/ab -c 20 -n 1000 CGI/脚本URL <br/>此命令表示使用 20 个并发连接，进行 1000 次请求。 <br/>所有测试均在本机进行，各种测试均反复进行5次，去掉最大最小值后取平均值。 <br/><br/>我分别测试了C写的CGI、Perl写的CGI、用mod_perl执行的Perl CGI、PHP和JSP。 <br/>各种CGI/脚本均输出内容相似的简单页面，内容如下： <br/>html <br/>body <br/>h1The xxxx Hello Program/h1 <br/>p <br/>Hello xxxx World! <br/>/body <br/>/html <br/><br/>测试结果(只取了最具代表性的 Requests per second 即每秒处理请求数这一项) <br/><br/>CGI/脚本类型 每秒处理请求数 <br/>C CGI 128 <br/>Perl CGI 69 <br/>mod_perl 223 <br/>PHP 237 <br/>JSP 21 <br/><br/>除了JSP之外，其它几种CGI/脚本的表现大致是正常的。Perl程序解释执行，作为 <br/>CGI运行时又需要另外fork进程，所以最慢；mod_perl和PHP都直接在httpd内部运 <br/>行脚本，省掉了fork的消耗，所以快了很多；C程序虽然本应最快，但作为CGI 运 <br/>行时也是因为fork而使性能大打折扣。 <br/><br/>至于JSP...我想这个结果并不具有代表性。毕竟测试用机只有192M内存，用top看 <br/>看，一个JAVA就占了11M。况且测试用机本身是一台Web server，测试时还有好几 <br/>十个httpd在跑 <br/><br/>不过不管怎么说，在配置较低的服务器上，跑PHP、mod_perl在性能上要好过JSP <br/>是肯定的。 <br/><br/>附测试用程序： <br/><br/><br/>C程序 hello.c <br/>#include stdio.h <br/><br/>int main(void) <br/>&#123; <br/>char s[] = &quot;C CGI&quot;; <br/>printf (&quot;Content-Type: text/html &quot;); <br/><br/>printf (&quot;html &quot; <br/>&quot;body &quot; <br/>&quot;h1The C CGI Hello Program/h1 &quot; <br/>&quot;p &quot; <br/>&quot;Hello %s World! &quot; <br/>&quot;/body &quot; <br/>&quot;/html &quot;, s); <br/>return 0; <br/>&#125; <br/><br/>用 gcc -o hello hello.c 编译，把 hello 放到 cgi-bin目录下。 <br/><br/>Perl程序 hello.pl <br/>#!/usr/bin/perl <br/>#!/usr/bin/perl <br/>$s = &quot;Perl CGI&quot;; <br/>print &quot;Content-Type: text/html &quot;; <br/>print &lt;&lt;DONE <br/>html <br/>body <br/>h1The Perl CGI Hello Program/h1 <br/>p <br/>Hello $s World! <br/>/body <br/>/html <br/>DONE <br/><br/>把hello.pl放到cgi-bin目录下，兼作Perl CGI和mod_perl 脚本测试用。 <br/><br/>PHP文件 hello.php <br/>html <br/>body <br/>h1The PHP Hello Program/h1 <br/>&lt;? $s = &quot;PHP&quot;; ?&gt; <br/>p <br/>Hello &lt;? echo $s ?&gt; World! <br/>/body <br/>/body <br/>/html <br/><br/>JSP文件 hello.jsp <br/>html <br/>body <br/>h1The JSP Hello Program/h1 <br/>p <br/>&lt;% String s = &quot;JSP&quot;; %&gt; <br/>p <br/>Hello &lt;%= s %&gt; World! <br/>/body <br/>/html<br/><br/> shenvo 回复于：2003-01-15 13:41:46跑jsp这么耗内存吗，这和运行什么样的服务器也有关系吧，请问斑竹tomcat,resin哪个性能更好些（同等条件下）<br/><br/> 南非蜘蛛 回复于：2003-01-15 13:44:32[quote:afe8c42037=&quot;shenvo&quot;]跑jsp这么耗内存吗，这和运行什么样的服务器也有关系吧，请问斑竹tomcat,resin哪个性能更好些（同等条件下）[/quote:afe8c42037]<br/>我觉得不要钱的好,纯属个人意见,不代表版本意见,呵呵<br/><br/> neteagle 回复于：2003-01-16 13:48:29我的ｔｏｍｃａｔ比较夸张，环境为redhat AS 2.1+apache1.3.27+tomcat 4.1.18,ｊｄｋ为IBMJDK1.3.1，数据库为ｏｒａｃｌｅ９Ｉ，开始时每个ｊａｖａ占用内存为２５Ｍ，随着访问的增加开始上升到１００多Ｍ，多时达到３００多Ｍ，没有访问后ｊａｖａ占用的内存并不释放，只有重起ｔｏｍｃａｔ才能释放内存，我一直找不到原因，蜘蛛你知道吗？<br/><br/> 南非蜘蛛 回复于：2003-01-16 13:55:17[quote:a9d1723b7c=&quot;neteagle&quot;]我的ｔｏｍｃａｔ比较夸张，环境为redhat AS 2.1+apache1.3.27+tomcat 4.1.18,ｊｄｋ为IBMJDK1.3.1，数据库为ｏｒａｃｌｅ９Ｉ，开始时每个ｊａｖａ占用内存为２５Ｍ，随着访问的增加开始上升到１００多Ｍ，多时达到..........[/quote:a9d1723b7c]<br/>是你的程序没有释放内存吧???<br/><br/> neteagle 回复于：2003-01-16 14:09:15对，ｔｏｍｃａｔ没有释放内存，一个ｊａｖａ仍然占用３００多Ｍ内存，<br/>只有重起ｔｏｍｃａｔ才能释放<br/><br/> 南非蜘蛛 回复于：2003-01-16 14:11:10[quote:de9500e94e=&quot;neteagle&quot;]对，ｔｏｍｃａｔ没有释放内存，一个ｊａｖａ仍然占用３００多Ｍ内存，<br/>只有重起ｔｏｍｃａｔ才能释放[/quote:de9500e94e]<br/>我查查资料,我觉得是你程序写的有问题,不是tomcat的问题<br/><br/> neteagle 回复于：2003-01-16 14:16:36我先用我自己的应用出现问题，<br/>后来用了你上面贴里的那个ｈｅｌｌｏｗｏｒｄ．ｊｓｐ<br/>用ａｂ测试<br/><br/> ygzq 回复于：2003-04-03 10:52:05[quote:07cc0e3071=&quot;南非蜘蛛&quot;]除了JSP之外，其它几种CGI/脚本的表现大致是正常的。Perl程序解释执行，作为<br/>CGI运行时又需要另外fork进程，所以最慢；mod_perl和PHP都直接在httpd内部运<br/>行脚本，省掉了fork的消耗，所以快了很多；C程序虽然本应最快，但作为CGI 运<br/>行时也是因为fork而使性能大打折扣。[/quote:07cc0e3071]<br/><br/><br/><br/>simple c cgi should be much more quicker than listed.<br/><br/>forking a perl takes about 4 MB memory while forking a simple c program can be ignored (yes still some overhead). <br/><br/>agree that c cgi should simple.<br/><br/>price for php and mod_perl is that you end up with a much larger httpd file which needs more resources to run - no free lunch as it says.&nbsp;&nbsp;so the system can be really slow when/before it establishes its httpd process pools, and when there are a lot of users so new httpd processes need to be created.<br/><br/> 麻辣 回复于：2003-10-20 01:47:45无意中发现这个帖子，我也测试了一下，和上面的结果完全不同<br/><br/>理论归理论，还是多实测，不同的代码不同的环境可能有不同的测试结果。<br/><br/>我的测试结果完全相反（在windows环境）perl普通状态（没有mod_perl)下不但不慢，还比PHP要快<br/><br/>测试完成相同加法运算，循环1000000次（如果您的机器配置比较底，可以减少循环次数）<br/><br/>雷鸟2000+ 256兆内存,考虑到加上编译时间，做了两个脚本：<br/>######perl.cgi#########<br/>#!/usr/bin/perl&nbsp;&nbsp;<br/>use Benchmark;&nbsp;&nbsp;<br/>$TT0 = new Benchmark;&nbsp;&nbsp;<br/>do &quot;test.cgi&quot;;#用DO命令调用test.cgi脚本来计算总时间<br/>exit;&nbsp;&nbsp;
]]>
</description>
</item><item>
<link>https://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] [转贴]CGI, mod_perl, PHP, JSP性能比较Web服务器教程]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>https://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>