Samuel Learning

  • 联系
  •  
  • 管理

文章分类(203)

  • 01 ASP/HTML(6)
  • 02 Script/CSS(16)
  • 03 C/C++
  • 04 XML(4)
  • 05 微软编程(26)
  • 06 J2EE(60)
  • 09 Linux(14)
  • 10 Database(27)
  • 11 报表打印
  • 12 打包安装(1)
  • 13 模式重构(2)
  • 14 系统架构
  • 15 敏捷开发(11)
  • 16 案例分析(30)
  • 17 Workflow(1)
  • 18 配置管理(1)
  • 19 项目管理
  • 20 英语(4)

新闻分类(52)

  • CXF学习
  • Hibernate学习(1)
  • iBatis学习(16)
  • Struts1学习(1)
  • Struts2学习(34)

.NET资源

  • adxmenu
  • C# Open Source
  • DNN Directory
  • M2Land
  • Windows Form FAQ
  • 中国DNN
  • 中国DNN联盟

Ajax

  • DoJo
  • GWT
  • JQuery
  • jquery autocomplete
  • jquery flexgrid
  • JQuery Form
  • jquery masked input
  • JQuery UI
  • jquery validation
  • Jquery 图表
  • jquery报表
  • jquery插件集合
  • Qooxdoo
  • Tibco GI
  • YUI
  • YUI-EXT
  • ZeroKode

Java开源

  • ABLE
  • Agile Tao
  • Ajax4JSF
  • Alfresco
  • AppFuse
  • Compiere
  • Equinox
  • Findbugs
  • Geronimo
  • Grails
  • Harmony
  • Hibernate论坛
  • JAG
  • Java开源大全
  • Java视线论坛
  • jBPM工作流
  • JSFTutorials
  • Nereide ERP
  • Ofbiz ERP
  • Opentaps ERP
  • operamasks
  • Petstore
  • Prototype.js
  • RIFE
  • Runa
  • SpringSide
  • Struts Menu
  • Sun Glassfish
  • Trails
  • YUI4JSF
  • 满江红

Mobile

  • Sencha

WEB资源

  • DHTML中心
  • DHTML参考手册
  • DHTML文档
  • EclipsePlugin
  • Firebug
  • GRO Clinux
  • jMaki
  • JSTL文档
  • LoadIcon
  • Openlaszlo
  • Struts Menu 展示
  • Web Test Tools
  • WebCtrs
  • Webdeveloper
  • 中国RIA开发者论坛

Workflow

  • E-Workflow
  • JBPM
  • OpenWFE
  • OSWorkflow
  • WFMC
  • Workflow Research

其他连接

  • confach
  • CPP
  • ejay
  • Giovanni
  • 丹佛
  • 交大e-learning
  • 交大研究生院
  • 可恶的猫
  • 天天@blog
  • 我的相册
  • 阿飞

大牛人

  • 32篇JBPM
  • David.Turing
  • HongSoft@业务集成
  • Joel
  • Koen Aers
  • Martinfowler
  • Raible Matt
  • Raible Wiki
  • Scott W.Ambler
  • Tom Baeyens
  • Uncle Bob
  • 一个世界在等待
  • 子在川上曰
  • 小布老师
  • 小明
  • 差沙
  • 徐昊
  • 江南白衣
  • 汪博士
  • 汪小金
  • 银狐999

开源软件

  • 2Bizbox ERP
  • CompiereCRM&ERP
  • EGW
  • Vtiger CRM
  • webERP

敏捷

  • Canoo
  • Cruisecontrol
  • DBUnit
  • EL4Ant
  • Extreme Programming
  • Fit
  • Fitnesse
  • JFrog
  • Liquibase
  • Maven
  • MockObjects
  • Selenium
  • Squish
  • xpairtise
  • XPlanner
  • XProgramming
  • 敏捷联盟

数据库

  • Oracle 中国
  • Oracle-ERP
  • Oracle在线社区

未归类

  • Aquarius Orm Studio
  • mambo建站系统
  • Oracle产品下载
  • 远程同步管理工具Capivara

经典框架

  • Apache Shale
  • formdef-struts
  • FreeMarker 主页
  • JBoss Seam
  • JSF 中心
  • JSF 入门应用
  • JSF中国
  • MyFaces官方
  • Spring 社区
  • Spring专业网站
  • Spring中文论坛
  • Spring参考手册
  • Spring官方网站
  • strecks-struts
  • Struts1
  • Struts2
  • Struts-layout
  • StrutsWiKi
  • Tapestry WIKI
  • Tapestry 官方
  • Tapestry4开发指南
  • Tapestry中文文档
  • Webwork2文档
  • Wicket

网络教程

  • Laliluna
  • RoseIndia
  • Sang Shin
  • Visualbuilder

著名站点

  • Buildix
  • Dev2Dev
  • IBM dev中国
  • InfoQ
  • ITPub
  • Java Eye
  • Java Research
  • JavaRead
  • JavaWorldTW
  • Matrix
  • PHP100
  • PHPX
  • SpringSideWiKi
  • TheServerSide
  • TWPHP
  • 中国工作流论坛

项目管理

  • 管理人网

最新评论

View Post

提高Tomcat性能

  一, 测试工具:

1, ab - Apache HTTP server benchmarking tool

  安装 Apatch2 之后,在 bin 目录下有这个命令,在控制台上运行 ab, 就可以看到帮助内容,大体如下:

D:\Apache2\bin>ab

ab: wrong number of arguments

Usage: ab [options] [http://]hostname[:port]/path

Options are:

    -n requests     Number of requests to perform

    -c concurrency  Number of multiple requests to make

    -t timelimit    Seconds to max. wait for responses

    -p postfile     File containing data to POST

    -T content-type Content-type header for POSTing

    -v verbosity    How much troubleshooting info to print

    -w              Print out results in HTML tables

    -i              Use HEAD instead of GET

    -x attributes   String to insert as table attributes

    -y attributes   String to insert as tr attributes

    -z attributes   String to insert as td or th attributes

    -C attribute    Add cookie, eg. 'Apache=1234. (repeatable)

    -H attribute    Add Arbitrary header line, eg. 'Accept-Encoding: gzip'

                    Inserted after all normal header lines. (repeatable)

    -A attribute    Add Basic WWW Authentication, the attributes

                    are a colon separated username and password.

    -P attribute    Add Basic Proxy Authentication, the attributes

                    are a colon separated username and password.

    -X proxy:port   Proxyserver and port number to use

    -V              Print version number and exit

    -k              Use HTTP KeepAlive feature

    -d              Do not show percentiles served table.

    -S              Do not show confidence estimators and warnings.

    -g filename     Output collected data to gnuplot format file.

    -e filename     Output CSV file with percentages served

    -h              Display usage information (this message)

显然 n 和 c 是最重要的两个选项。

 

 

2,Apache-JMeter

       JMeter 是 Apache 开源项目里的一个单独项目,功能比较全面,解压缩之后可以阅读文档。测试 web 的顺序是先建立线程组,再建立 Http 请求,最后建立 2 个观察结果的项:用表格和 summary report.

 

 

二, 测试过程:

 

环境:内存 1G , Tomcat5.5.17, JDK1.5.

 

我要压力测试代表性页面: http://61.172.192.35/nrc/publik/demo/customers.htm 这个页面查询 500 条记录, 并且在页面上显示 100 条记录。

并发线程数: 20

共访问次数: 1000

 

测试之前,

1,  在 JVM 级别上做优化,修改了 catalina.bat 文件中 -Xms 和 –Xmx 两个参数,一般设置为内存的 80% ,因为机器内存是 1GB, 所以,改为:  -Xms819m -Xmx819m 。

2,  禁止 Tomcat 的 DNS 解析,其实 Tomcat 默认就是禁止解析的。

 

用 ab 进行测试:

命令: D:\Apache2\bin>ab -c 20 -n 1000 http://61.172.192.35/snrc/publik/demo/customers.htm >> d:\stress.txt

 

未启用 APR 之前,运行结果如下:

Server Software:        Apache-Coyote/1.1

Server Hostname:        61.172.192.35

Server Port :            80

 

Document Path:          /nrc/publik/demo/customers.htm

Document Length:        3277 bytes

 

Concurrency Level:      20

Time taken for tests:   601.328125 seconds

Complete requests:      1000

Failed requests:        999

   (Connect: 0, Length: 999, Exceptions: 0)

Write errors:           0

Non-2xx responses:      16

Total transferred:      73815422 bytes

HTML transferred:       73541950 bytes

Requests per second:    1.66 [#/sec] (mean)

Time per request:       12026.563 [ms] (mean)

Time per request:       601.328 [ms] (mean, across all concurrent requests)

Transfer rate:          119.88 [Kbytes/sec] received

 

Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0    2   5.3      0      31

Processing:  1265 11946 14632.7   9859  121656

Waiting:      640 8245 14931.0   6421  121656

Total:       1265 11948 14633.1   9859  121671

 

Percentage of the requests served within a certain time (ms)

  50%   9859

  66%  10515

  75%  10937

  80%  11343

  90%  12796

  95%  14921

  98%  57359

  99%  119890

 100%  121671 (longest request)

 

启用 APR 之后的结果:

Server Software:        Apache-Coyote/1.1

Server Hostname:        61.172.192.35

Server Port :            80

 

Document Path:          /nrc/publik/demo/customers.htm

Document Length:        74705 bytes

 

Concurrency Level:      20

Time taken for tests:   601.500000 seconds

Complete requests:      1000

Failed requests:        911

   (Connect: 0, Length: 911, Exceptions: 0)

Write errors:           0

Non-2xx responses:      16

Total transferred:      73808906 bytes

HTML transferred:       73535578 bytes

Requests per second:    1.66 [#/sec] (mean)

Time per request:       12030.000 [ms] (mean)

Time per request:       601.500 [ms] (mean, across all concurrent requests)

Transfer rate:          119.83 [Kbytes/sec] received

 

Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0    1   5.1      0      31

Processing:  3703 11952 15032.6   9375  120593

Waiting:      593 7073 15476.2   4906  120593

Total:       3703 11954 15032.5   9375  120593

 

Percentage of the requests served within a certain time (ms)

  50%   9375

  66%  10250

  75%  11093

  80%  11687

  90%  13734

  95%  15750

  98%  70812

  99%  119937

 100%  120593 (longest request)

 

用 JMeter 进行测试:

下栽 tcnative-1.dll ,放在 tomcat/apr/tcnative-1.dll, 修改 catalina.bat 中 JAVA_OPTS  -Djava.library.path="%CATALINA_BASE%\arp"

 

未启用 APR, 结果如下:

Summary Report1.png
起用
APR, 结果如下:

 Summary Report2.png

对比两个结果,启动 APR ,效果并不十分明显。可能做 load balance 效果会更明显。

 

 

三, 解决办法总结:

1,  优化 JVM 的内存数量;

2,  禁止 DNS 解析;

3,  启用 APR ;

是否启动了 APR ? 在 Tomcat 启动之后,看到:xxxxx http11BaseProtocol Start 表示没有启用 APR

xxxxx http11AprProtocol Star 表示启用了 APR

 

 

 

四, 待续

用一个 Apache2 + 2 个 Tomcat 在一台服务器上做负载均衡。

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

posted on 2006-12-11 19:32 MingIsMe 阅读(269) 评论(0)  编辑  收藏 所属分类: 06 J2EE

 
Powered by:
BlogJava
Copyright © MingIsMe