免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3589 | 回复: 9
打印 上一主题 下一主题

[Web] apache与tomcat性能的困惑 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-07-25 10:50 |只看该作者 |倒序浏览
各位好:
  
  初学apache。印象中,apache2.2的效率会高于tomcat5。可是试验下来,结果让我感到奇怪。apache2.2的响应反而不及tomcat。无论是静态页面还是动态页面,结果都是apache不敌tomcat。

  机器环境:win xp sp2
  软件:apache2.2.4,tomcat5.0.28。

  下面是ab测试结果。
==========================
tomcat5结果:

Server Software:        Apache-Coyote/1.1
Server Hostname:        localhost
Server Port:            8080

Document Path:          /index.html
Document Length:        44 bytes

Concurrency Level:      100
Time taken for tests:   0.828125 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      265000 bytes
HTML transferred:       44000 bytes
Requests per second:    1207.55 [#/sec] (mean)
Time per request:       82.813 [ms] (mean)
Time per request:       0.828 [ms] (mean, across all concurrent requests)
Transfer rate:          311.55 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   2.4      0      15
Processing:    15   78  13.7     78     109
Waiting:        0   39  24.0     46      93
Total:         15   78  13.9     78     109

Percentage of the requests served within a certain time (ms)
  50%     78
  66%     78
  75%     78
  80%     93
  90%     93
  95%     93
  98%     93
  99%    109
100%    109 (longest request)



==========================
apache结果:

Server Software:        Apache
Server Hostname:        localhost
Server Port:            80

Document Path:          /index.html
Document Length:        44 bytes

Concurrency Level:      100
Time taken for tests:   1.78125 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      274000 bytes
HTML transferred:       44000 bytes
Requests per second:    927.54 [#/sec] (mean)
Time per request:       107.813 [ms] (mean)
Time per request:       1.078 [ms] (mean, across all concurrent requests)
Transfer rate:          247.65 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.9      0      15
Processing:    15  101  19.3    109     125
Waiting:        0   52  30.2     46     125
Total:         15  102  19.2    109     125

Percentage of the requests served within a certain time (ms)
  50%    109
  66%    109
  75%    109
  80%    109
  90%    125
  95%    125
  98%    125
  99%    125
100%    125 (longest request)

以上的结果多次执行的结果中的一次(结果都是差不多),应该可以看成是平均情况了。
测试的静态页面是apache的index.html,44bytes。

我的apache配置是:
ThreadsPerChild 1920
MaxRequestsPerChild  20000
KeepAlive On
MaxKeepAliveRequests 200
KeepAliveTimeout 10
Timeout 300
ServerSignature Off
HostnameLookups Off
ServerTokens Prod
UseCanonicalName Off

这个配置有问题吗?为什么结果会比不上tomcat?

[ 本帖最后由 xsun17951 于 2007-7-25 20:13 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2007-07-25 11:31 |只看该作者
apache的响应速度也不及tomcat。
是apache的配置有问题吗?

[ 本帖最后由 xsun17951 于 2007-7-25 12:02 编辑 ]

论坛徽章:
0
3 [报告]
发表于 2007-07-25 13:40 |只看该作者
那就把你的 apache 的配置貼出來啊

你光說你有病,又不讓醫生把脈看相,怎麽毉

论坛徽章:
0
4 [报告]
发表于 2007-07-25 19:57 |只看该作者
httpd.conf配置如下:
==========
ThreadsPerChild 1920
MaxRequestsPerChild  20000

ServerRoot "D:/java/Apache2.2"

Listen 80

LoadModule actions_module modules/mod_actions.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule file_cache_module modules/mod_file_cache.so
LoadModule imagemap_module modules/mod_imagemap.so
LoadModule include_module modules/mod_include.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule setenvif_module modules/mod_setenvif.so

# --begin
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workersb.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
JkMount /*.action loadbalancer
JkMount /*.do loadbalancer
JkMount /*.jsp loadbalancer
#--end

#--begin
ServerTokens Prod
ServerSignature Off
MaxKeepAliveRequests 200
Timeout 300
KeepAlive On
KeepAliveTimeout 10
#--end

Timeout 300
ServerSignature Off
HostnameLookups Off
ServerTokens Prod
UseCanonicalName Off

ServerAdmin test@test.com

ServerName :80

DocumentRoot "D:/java/Apache2.2/htdocs"

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Satisfy all
</Directory>

<Directory "D:/java/Apache2.2/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
</FilesMatch>

ErrorLog logs/error.log

LogLevel info

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    LogFormat "%h %l %u %t %>s %b" sun

    <IfModule logio_module>     
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    CustomLog logs/access.log sun

</IfModule>

DefaultType text/plain

<IfModule mime_module>
    TypesConfig conf/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
</IfModule>

<IfModule ssl_module>
    SSLRandomSeed startup builtin
    SSLRandomSeed connect builtin
</IfModule>

==============
配置就是上面这些,没有贴注释。

[ 本帖最后由 xsun17951 于 2007-7-25 20:14 编辑 ]

论坛徽章:
0
5 [报告]
发表于 2007-07-26 09:07 |只看该作者
谁能给一个apache在win xp (1G~2G内存)下的配置方案啊?

[ 本帖最后由 xsun17951 于 2007-7-26 09:12 编辑 ]

论坛徽章:
0
6 [报告]
发表于 2007-07-26 13:54 |只看该作者
你是用得 worker 的 httpd ?

startservers , maxclients 是?

很可惜,我對 windows 下的調優沒什麽 idea

[ 本帖最后由 alvis 于 2007-7-26 14:17 编辑 ]

论坛徽章:
0
7 [报告]
发表于 2007-07-26 20:45 |只看该作者
你XP放个apache还要进行关键服务?

无解,换个server的版本吧,win系统下还是IIS的索

论坛徽章:
0
8 [报告]
发表于 2007-07-26 21:16 |只看该作者
to wigeboy :

 只是初学,试试看,没有打算用于生产环境。 


可能是apache对win支持没有linux好吧,调来调去响应速度总是不太理想,试下linux再说。


感谢各位的支持~

[ 本帖最后由 xsun17951 于 2007-7-26 21:20 编辑 ]

论坛徽章:
0
9 [报告]
发表于 2007-07-28 08:49 |只看该作者
建议楼主:Apache,Tomcat 都暂时放一放。

去测试 Resin 或者 GlassFish 吧。

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
10 [报告]
发表于 2007-07-28 15:41 |只看该作者
winxp我建议使用IIS效率更好的多。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP