锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲电影唐人社一区二区,亚洲av成人无码久久精品,国产成人亚洲综合一区 http://www.tkk7.com/gdufo/category/32717.htmlzh-cnSat, 02 Jun 2012 03:50:06 GMTSat, 02 Jun 2012 03:50:06 GMT60TOMCAT6閰嶇疆璐熻澆鍧囪 鍜岄泦緹?_2http://www.tkk7.com/gdufo/archive/2012/06/02/379786.htmlgdufogdufoSat, 02 Jun 2012 00:55:00 GMThttp://www.tkk7.com/gdufo/archive/2012/06/02/379786.html

http://blog.csdn.net/dangerous_fire/article/details/6278435

鏈榪戣閰嶇疆tomcat闆嗙兢錛屽湪緗戜笂鎼滀簡寰堝鏂囩珷錛屼絾鐓х潃姝ラ涓姝ヤ竴姝ュ仛鍒版渶鍚庡嵈鏃犳硶鎴愬姛錛岀潃浣挎垜璐逛簡涓ゅぉ鐨勫姴鏌ョ湅浜哸pache 鍜? tomcat鐨勫ぇ閲忔枃妗o紝鎵嶅皢闂涓涓瑙e喅銆備負鏂逛究鑷繁鍜屾柊鎵嬮厤緗畉omcat闆嗙兢錛屾垜灝嗘暣鐞嗗ソ鐨勮繃紼嬫檼涓鏅掞紝甯屾湜鍙互甯埌鍚庢潵浜哄皯璧頒竴浜涘集璺?/p>

==================

鐩爣:
浣跨敤 apache 鍜?tomcat 閰嶇疆涓涓彲浠ュ簲鐢ㄧ殑 web 緗戠珯錛岃杈懼埌浠ヤ笅瑕佹眰錛?
1銆?Apache 鍋氫負 HttpServer 錛屽悗闈㈣繛鎺ュ涓?tomcat 搴旂敤瀹炰緥錛屽茍榪涜璐熻澆鍧囪 銆?
2銆?涓虹郴緇熻瀹?Session 瓚呮椂鏃墮棿錛屽寘鎷?Apache 鍜?tomcat
3銆?涓虹郴緇熷睆钄芥枃浠跺垪琛紝鍖呮嫭 Apache 鍜?tomcat

娉細鏈緥紼嬩互涓鍙版満鍣ㄤ負渚嬪瓙錛屽嵆鍚屼竴鍙版満鍣ㄤ笂瑁呬竴涓猘pache鍜?涓猅omcat銆?/p>

涓銆佸墠鏈熷噯澶囧伐浣滐細瀹夎鐢ㄧ殑紼嬪簭錛堝墠鎻愪繚璇佸凡瀹夎浜咼DK1.5浠ヤ笂鐨勭増鏈級
APAHCE 2.2.8涓嬭澆錛歛pache_2.2.8-win32-x86-no_ssl.msi
TOMCAT6.0.14涓嬭澆錛歛pache-tomcat-6.0.14.zip鐩存帴瑙e帇銆?/p>

浜屻佸畨瑁呰繃紼?br />APAHCE瀹夎鐩綍錛欴:/Apache銆?
涓や釜TOMCAT鐩綍錛氳嚜琛岃В鍘嬪埌(D:/TomcatCluster/)涓嬨?br />鍒嗗埆涓?tomcat6-a錛宼omcat6-b

涓夈侀厤緗?
1銆丄pache閰嶇疆
1.1 httpd.conf閰嶇疆
淇敼APACHE鐨勯厤緗枃浠禗:/Apache/conf/httpd.conf

榪欓噷騫舵病鏈変嬌鐢╩od_jk.so榪涜apache鍜宼omcat鐨勯摼鎺ワ紝浠?.X浠ュ悗apache鑷韓宸查泦鎴愪簡mod_jk.so鐨勫姛鑳姐傚彧闇綆鍗曠殑鎶婁笅闈㈠嚑琛屽幓鎺夋敞閲婏紝灝辯浉褰撲簬浠ュ墠鐢╩od_jk.so姣旇緝綣佺悙鐨勯厤緗簡銆?br />榪欓噷涓昏閲囩敤浜嗕唬鐞嗙殑鏂規(guī)硶錛屽氨榪欎箞綆鍗曘?/p>

灝嗕互涓婱odule鐨勬敞閲婂幓鎺?br />LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so

鍐嶆壘鍒?br /><IfModule dir_module>
DirectoryIndex index.html
</IfModule>
鍔犱笂index.jsp淇敼鎴?

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

姝ゅ娣誨姞index.jsp 涓昏涓轟簡閰嶇疆瀹屾垚浠ュ悗鍒╃敤index.jsp杈撳嚭嫻嬭瘯淇℃伅錛?/p>

鍦?httpd.conf 鏈鍚庨潰鍔犲叆
ProxyRequests Off
<proxy balancer://cluster>
BalancerMember ajp://127.0.0.1:8009 loadfactor=1 route=jvm1
BalancerMember ajp://127.0.0.1:9009 loadfactor=1 route=jvm2
</proxy>

涓婇潰鐨勪袱涓狟alancerMember鎴愬憳鏄垜浠厤緗殑tomcat闆嗙兢銆?/p>


1.2 httpd-vhosts.conf璁劇疆
鎺ヤ笅鏉ヨ繘琛岃櫄鎷熶富鏈虹殑璁劇疆銆?br />APACHE鐨勮櫄鎷熶富鏈鴻緗涓嬶細
棣栧厛瑕佷慨鏀?conf/httpd.conf
鎵懼埌

# Virtual hosts
#Include conf/extra/httpd-vhosts.conf

鎶奍nclude璇彞娉ㄩ噴鍘繪帀銆傛敼鎴?

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

鍦ㄦ枃浠訛紙extra/httpd-vhosts.conf錛夋渶涓嬮潰鍔犲叆

<VirtualHost *:80>
 ServerAdmin adminname
 ServerName localhost
 ServerAlias localhost
 ProxyPass / balancer://cluster/ stickysession=jsessionid nofailover=On lbmethod=bytraffic
 ProxyPassReverse / balancer://cluster/
</VirtualHost>

鍏朵腑鐨勫煙鍚嶅拰璺緞鏍規(guī)嵁浣犺嚜宸辨儏鍐佃緗?

璐熻澆鍧囪 鏈変笁縐嶆柟寮忥紝鍙互閫氳繃璁劇疆 lbmethod 閫夋嫨鑷繁闇瑕佺殑鏂瑰紡錛岃緇嗗彲鏌ョ湅apache鏂囨。

proxy鏄綅浜庡鎴風涓庡疄闄呯殑鏈嶅姟鍣ㄤ箣闂寸殑鏈嶅姟鍣紝涓鑸О涓篺acade server錛岃礋璐e皢澶栭儴鐨勮姹傚垎嫻侊紝涔熻礋璐e鍐呴儴鐨勫搷搴斿仛涓浜涘繀瑕佺殑澶勭悊銆?br />濡傛灉緇撳悎mod_cache錛屽垯鍙彁楂樿闂熷害錛岄傚綋鐨勫噺杞葷綉緇滄祦閲忓帇鍔涖?br />闂茶瘽灝戣錛岀洿鎺ユ嬁涓緥瀛愭潵錛?br />    璁炬湰绔欏湴鍧涓?www.test.com
    ProxyPass /images/ !
    ProxyPass /js/ !
    ProxyPass /css/ !
    ProxyPass /example http://www.example.com/
    ProxyPassReverse /example http://www.example.com/
    ProxyPass / ajp://127.0.0.1:8009/
    ProxyPassReverse / ajp://127.0.0.1:8009/
榪樻槸涓婁竴綃囩殑渚嬪瓙錛孭roxyPass鏄撶悊瑙o紝灝辨槸杞彂url涓婄殑璇鋒眰錛岃屽叾涓殑閰嶇疆欏哄簭涔熸槸闇瑕侀伒瀹堛?br />瑕佺姝㈣漿鍙戠殑url闇瑕佹斁鍦ㄤ竴鑸殑璇鋒眰涔嬪墠銆?br />瀵逛簬
http://www.test.com/images/ 
http://www.test.com/js/
http://www.test.com/css/
鐨勮姹傛槸涓嶄簣杞彂鐨勶紝瀵逛簬http://www.test.com/example/鐨勮姹傦紝浼氳漿鍙戝埌http://www.example.com銆?br />鍊煎緱娉ㄦ剰鐨勫氨鏄疨roxyPassReverse鐨勯厤緗簡錛岃繖鏄弽鍚戜唬鐞嗐?br />涓轟粈涔堣鍦ㄨ繖閲屽姞涓婅繖鏍風殑閰嶇疆錛熸垜浠潵鐪嬩釜渚嬪瓙錛?br /> 鍦ㄦ病鏈夊姞榪欐牱鐨勫弽鍚戜唬鐞嗚緗殑鎯呭喌涓嬶紝璁塊棶http://www.test.com/example/a錛?br /> 濡傛灉www.example.com瀵硅姹傝繘琛屼簡redirect鑷?a >http://www.example.com/b錛?br /> 閭d箞錛屽鎴風灝變細緇曡繃鍙嶅悜浠g悊錛岃繘鑰岃闂?a >http://www.test.com/example/b銆?br /> 濡傛灉璁劇疆浜嗗弽鍚戜唬鐞嗭紝鍒欎細鍦ㄨ漿浜TTP閲嶅畾鍚戝簲絳斿埌瀹㈡埛绔箣鍓嶈皟鏁村畠涓?a >http://www.test.com/example/a/b
 鍗蟲槸鍦ㄥ師璇鋒眰涔嬪悗榪藉姞涓婁簡redirect鐨勮礬寰勩?br />鏇村鏇磋緇嗙殑鍏充簬mod_proxy鐨勬弿榪板彲浠ュ弬瑙佹墜鍐岋細
http://lamp.linux.gov.cn/Apache/ApacheMenu/mod/mod_proxy.html


2 閰嶇疆 tomcat
2.1 閰嶇疆 server 鐨勫叧闂?
鎴戜滑闇瑕佸湪涓鍙版満鍣ㄤ笂璺戜袱涓笉鍚岀殑 tomcat 錛岄渶瑕佷慨鏀逛笉鍚岀殑 tomcat 鐨勫叧闂彛錛岄伩鍏嶅嚭鐜扮鍙h鍗犵敤鐨勬儏鍐點?br />鍏朵腑tomcat6-a鐢ㄩ粯璁ゅ鹼紝涓嶄慨鏀廣?br />tomcat6-b淇敼銆傚湪tomcat6-b/conf涓嬬殑 server.xml 涓壘鍒?server, 灝嗭細
<Server port="8005" shutdown="SHUTDOWN">
鏀逛負
<Server port="9005" shutdown="SHUTDOWN">

2.2 閰嶇疆 Engine
鎶婂師鏉ョ殑閰嶇疆娉ㄩ噴鎺夛紝鎶婁笅闈竴鍙ュ幓鎺夋敞閲娿傚茍鏍囨槑jvmRoute="jvm2"
<Engine name="Standalone" defaultHost="localhost" jvmRoute="jvm2">

浠ヤ笅鏄師鏉ョ殑閰嶇疆銆?br /><Engine name="Catalina" defaultHost="localhost">
 
2.3. 閰嶇疆 Connector
鍘熸潵鐨勯粯璁ら厤緗?

<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

灝唗omcal6-b 涓殑 protocol="HTTP/1.1" 鐨?Connector 绔彛鏀逛負 8081 閬垮厤鍐茬獊銆倀omcat6-a 涓殑淇濇寔涓嶅彉銆?br />protocol="AJP/1.3" 鐨?Connector 鏄痑pache鍜宼omcat閾炬帴鐨勫叧閿紝鍓嶅彴apache灝辨槸閫氳繃AJP鍗忚涓巘omcat榪涜閫氫俊鐨勶紝浠ュ畬鎴愯礋杞藉潎琛$殑浣滅敤銆?br />涔熷彲浠ョ敤HTTP鍗忚銆傚ぇ瀹舵敞鎰忓畠浠槸濡備綍榪炴帴閫氫俊鐨勶紝錛坧ort="8009"錛夊氨鏄繛鎺ョ殑鎺ュ彛浜嗐?

鎶妕omcat6-b鐨?lt;Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> 涓殑port鏀規(guī)垚 9009
<proxy balancer://cluster>
#涓?tomcat6-a 瀵瑰簲錛宺oute涓?lt;Engine jvmRoute="jvm1">瀵瑰簲銆?
BalancerMember ajp://127.0.0.1:8009 loadfactor=1 route=jvm1
#涓?tomcat6-b 瀵瑰簲錛宺oute涓?lt;Engine jvmRoute="jvm2">瀵瑰簲銆?
BalancerMember ajp://127.0.0.1:9009 loadfactor=1 route=jvm2
</proxy>

涓殑绔彛瀵瑰簲錛?br />tomcat6-a 鐨刟jp绔彛port:8009
tomcat6-b 鐨刟jp绔彛port:9009
涓瀹氳涓庝笂闈㈢殑涓鑷淬?/p>

2.5.閰嶇疆Cluster(涓や釜tomcat涓兘瑕佷慨鏀?
鍘熸潵鐨勯厤緗?
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
淇敼涓轟互涓嬬殑浠g爜錛?lt;Receiver port=”XX”/>port涔熻淇濊瘉鍞竴鎬с?

<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"? channelSendOptions="6">
 <Manager className="org.apache.catalina.ha.session.BackupManager"
  expireSessionsOnShutdown="false"
  notifyListenersOnReplication="true"
  mapSendOptions="6"/>
 <!--
 <Manager className="org.apache.catalina.ha.session.DeltaManager"
  expireSessionsOnShutdown="false"
  notifyListenersOnReplication="true"/>
 -->
 <Channel className="org.apache.catalina.tribes.group.GroupChannel">
  <Membership className="org.apache.catalina.tribes.membership.McastService"
   address="228.0.0.4"
   port="45564"
   frequency="500"
   dropTime="3000"/>
  <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
   address="auto"
   port="5001"
   selectorTimeout="100"
   maxThreads="6"/>
  <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
   <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
  </Sender>
  <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
  <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
  <Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>
 </Channel>
 <Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
  filter=".*/.gif;.*/.js;.*/.jpg;.*/.png;.*/.htm;.*/.html;.*/.css;.*/.txt;"/>
 <Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
  tempDir="/tmp/war-temp/"
  deployDir="/tmp/war-deploy/"
  watchDir="/tmp/war-listen/"
  watchEnabled="false"/>
 <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
</Cluster>

榪欎釜璁劇疆鏄富瑕佺敤浠omcat鐨勯泦緹ゃ?br />tomcat闆嗙兢鍚勮妭鐐歸氳繃寤虹珛tcp閾炬帴鏉ュ畬鎴怱ession鐨勬嫹璐濓紝鎷瘋礉鏈夊悓姝ュ拰寮傛涓ょ妯″紡銆?br />鍦ㄥ悓姝ユā寮忎笅錛屽瀹㈡埛绔殑鍝嶅簲蹇呴』鍦⊿ession鎷瘋礉鍒板叾浠栬妭鐐瑰畬鎴愬悗榪涜錛涘紓姝ユā寮忔棤闇絳夊緟Session鎷瘋礉瀹屾垚灝卞彲鍝嶅簲銆?br />寮傛妯″紡鏇撮珮鏁堬紝浣嗘槸鍚屾妯″紡鍙潬鎬ф洿楂樸傚悓姝ュ紓姝ユā寮忕敱channelSendOptions鍙傛暟鎺у埗錛岄粯璁ゅ兼槸8錛屼負寮傛妯″紡錛?鏄悓姝ユā寮忋?br />鍦ㄥ紓姝ユā寮忎笅錛屽彲浠ラ氳繃鍔犱笂鎷瘋礉紜錛圓cknowledge錛夋潵鎻愰珮鍙潬鎬э紝姝ゆ椂channelSendOptions璁句負10銆?/p>

Manager鐢ㄦ潵鍦ㄨ妭鐐歸棿鎷瘋礉Session錛岄粯璁や嬌鐢―eltaManager錛孌eltaManager閲囩敤鐨勪竴縐峚ll-to-all鐨勫伐浣滄柟寮忥紝
鍗抽泦緹や腑鐨勮妭鐐逛細鎶奡ession鏁版嵁鍚戞墍鏈夊叾浠栬妭鐐規(guī)嫹璐濓紝鑰屼笉綆″叾浠栬妭鐐規(guī)槸鍚﹂儴緗蹭簡褰撳墠搴旂敤銆?br />褰撻泦緹や腑鐨勮妭鐐規(guī)暟閲忓緢澶氬茍涓旈儴緗茬潃涓嶅悓搴旂敤鏃訛紝鍙互浣跨敤BackupManager錛孊ackManager浠呭悜閮ㄧ講浜嗗綋鍓嶅簲鐢ㄧ殑鑺傜偣鎷瘋礉Session銆?br />浣嗘槸鍒扮洰鍓嶄負姝ackupManager騫舵湭緇忚繃澶ц妯℃祴璇曪紝鍙潬鎬т笉鍙奃eltaManager銆?/p>

鍥涖佸惎鍔ㄦ湇鍔★紝嫻嬭瘯tomcat鑷甫鐨勪緥瀛?
1銆佹祴璇昦pache鍜宼omcat鍗忎綔銆?
鍏堝湪姣忎釜tomcat涓殑/webapps/ROOT涓嬬殑index.jsp涓嬮潰鍔犱笂浠ヤ笅鐨勬祴璇曚唬鐮侀儴鍒嗭細
(X浠h〃涓嶅悓鐨則omcat鐨勮緭鍑轟笉鍚岀殑淇℃伅)錛屾妸index.html鍒犻櫎錛屼互鍏嶅獎鍝嶆祴璇曟晥鏋溿?br />鍦ㄦ渶鍚庨潰鐨勫姞涓?鍗?lt;/table></body>涔嬮棿銆?
<%
 System.out.println("tomcat6 A|B deal with request");
%>
鐒跺悗鍐嶉氳繃http://127.0.0.1鏉ヨ闂竴涓嬶紝灝變細鍑虹幇澶у鐔熸?zhèn)夌殑鐚尗銆?
鐒跺悗鍐嶉氳繃鍒嗗埆璁塊棶
http://127.0.0.1:8080
http://127.0.0.1:8081


瀹冧滑璁塊棶鐨勫唴瀹瑰拰涓婇潰鐨刪ttp:// 127.0.0.1鏄竴鏍風殑銆?
榪欐牱灝辮鏄巃pache鍜孴OMCAT鏁村悎鎴愬姛錛?
2銆佹祴璇曞潎琛″櫒
濡傛灉鍦?extra/httpd-vhosts.conf 涓厤緗?娌℃湁璁劇疆 lbmethod=bytraffic錛屽皢浣跨敤榛樿鐨?byrequests 錛屾帶鍒跺垎閰嶇殑涓鍏辨湁涓夌鏂瑰紡錛岃繕鏈変竴縐嶆槸 bybusyness 銆?br />閫氳繃http://127.0.0.1澶氭璁塊棶錛?br />濡?鏋滀嬌鐢ㄧ殑鏄?byrequests 鐨勫垎閰嶆柟寮忥紝瑕佹兂鐪嬪埌鐪熸鐨勬晥鏋滐紝蹇呴』鐢ㄤ竴浜涘帇鍔涙祴璇曞伐鍏鳳紝鍙敤寰蔣Microsoft Web Application Stress Tool榪涜綆鍗曞帇鍔涙祴璇曪紝涓嶇劧浣犻潬涓嶅仠鍒鋒柊鏄綋鐜頒笉鍑烘潵鐨勶紝浣犲彧浼氬湪涓涓猼omcat鐨勬帶鍒跺彴鏈夎緭鍑虹粨鏋溿?br />鍙敤鐢ㄥ帇鍔涙祴璇曞伐鍏鋒ā鎷熷ぇ閲忕敤鎴峰悓鏃惰闂紝浣犱細鍙戠幇鍥涗釜tomcat鎺у埗鍙板潎鏈夋墦鍑烘帶鍒朵俊鎭紝璇存槑鍧囪 鍣ㄥ伐浣滄甯搞?
鑰屽鏋滈厤緗負 bytraffic 騫朵笖tomcat6-a 鍜?tomcat6-b 璁劇疆浜?loadfactor=1錛屽垯璇鋒眰浼氬潎鍖鐨勫垎閰嶇粰涓嶅悓鐨則omcat錛屽緢瀹規(guī)槗嫻嬭瘯鍑烘潵銆?br />濡傛灉鎯沖姝ゆ劅鍏磋叮錛岃鏌ョ湅apache 鐨勬枃妗e茍灝濊瘯淇敼
httpd.conf
----------------------
ProxyRequests Off
<proxy balancer://cluster>
BalancerMember ajp://127.0.0.1:8009 loadfactor=1 route=jvm1
BalancerMember ajp://127.0.0.1:9009 loadfactor=1 route=jvm2
</proxy>
----------------------
 涓殑 loadfactor  鍙傛暟鍜?br />extra/httpd-vhosts.conf
----------------------
<VirtualHost *:80>
 ServerAdmin adminname
 ServerName localhost
 ServerAlias localhost
 ProxyPass / balancer://cluster/ stickysession=jsessionid nofailover=On lbmethod=bytraffic
 ProxyPassReverse / balancer://cluster/
</VirtualHost>
----------------------
涓殑 lbmethod 鍙傛暟


娉ㄦ剰錛氬鏋渁pache 涓嚭鐜板涓嬮敊璇?br />Encountered too many errors accepting client connections. Possible causes: dynamic address renewal, or incompatible VPN or firewall software. Try using the Win32DisableAcceptEx directive.

緙栬緫httpd.conf 鍔犲叆
Win32DisableAcceptEx ##鍔犲叆榪欒
閲嶅惎apache灝辮В鍐充簡銆?/p>

濡傛灉淇敼鍚庤繕鏄笉琛岋紝浠葷劧鏈夐敊璇褰曪紝
cmd涓?br />netsh winsock reset

鍥犱負榪欎釜閿欒鍙兘涓巜insock鏈夊叧錛屾湁緗戝弸涔熷嚭鐜頒簡榪欎釜闂錛屼粬璁や負鏄噾灞辨瘨闇告垨鑰呭崌綰х簿鐏典慨鏀逛簡WINSOCK瀵艱嚧鐨勩傛垜娌℃湁瀹夎浣嗘槸緋葷粺緇忓父鑷姩鏇存柊錛屽埆鐨勮蔣浠朵篃鏈?鍙兘浼氭湁鍐茬獊銆?br />浣跨敤姝ゆ潯鍛戒護鎭㈠Winsock鍚庯紝閲嶅惎鐢?shù)鑴戝悗杩欎釜闂灏变細瑙e喅浜嗐?/div>

gdufo 2012-06-02 08:55 鍙戣〃璇勮
]]>
Tomcat6.0璐熻澆鍧囪 絳栫暐 _ 1http://www.tkk7.com/gdufo/archive/2012/06/02/379785.htmlgdufogdufoSat, 02 Jun 2012 00:54:00 GMThttp://www.tkk7.com/gdufo/archive/2012/06/02/379785.htmlhttp://www.cnblogs.com/shiyangxt/archive/2009/02/26/1398902.html

               寮瀛︿互鍚庯紝榪炵畫鍑犲ぉ浼戞伅涓嶅ソ錛屾繪槸鐘洶錛屼篃璁歌繖灝辨槸“鏄ュ洶縐嬩箯”鐨勭棁鐘跺惂銆傛渶榪戣佸笀鎻愬嚭浜嗚礋杞藉潎琛″姛鑳界殑闇姹傦紝浠ュ噺杞?/p>

緗戠珯鐨勯珮宄版湡鐨勬湇鍔″櫒璐熸媴錛岀幇鍦ㄥ鏍$殑紜歡璁炬柦榪樻槸铔ソ鐨勶紝鏈変笁錛屽洓鍙版湇鍔″櫒鍙互鎻愪緵浣跨敤錛屼篃寰堝ぇ紼嬪害鐨勪笂鏂逛究浜嗘垜鍋氫竴浜涙祴璇曘?/p>

鍥犱負榪欎釜瀛愰」鐩紝鍋囨湡涓変釜鍚屽宸茬粡鍩烘湰瀹屽伐錛屾墍浠ユ垜涔熷彧鑳藉嚭鐐瑰井钖勪箣鍔涳紝鎶婅繖涓礋杞藉潎琛℃悶瀹氾紝鍏蜂綋鐢ㄤ笉鐢ㄦ垜涓嶇錛岃搗鐮佹槸鎴戠殑涓涓?/p>

灝忓姛鑳姐?/p>

 

               鍏跺疄鏃犺鏄垎甯冨紡錛屾暟鎹紦瀛橈紝榪樻槸璐熻澆鍧囪 錛屾棤闈炲氨鏄敼鍠勭綉绔欑殑鎬ц兘鐡墮錛屽湪緗戠珯婧愮爜涓嶅仛浼樺寲鐨勬儏鍐典笅錛岃礋杞藉潎琛″彲浠ヨ

鏄渶鐩存帴鐨勬墜孌典簡銆傚叾瀹炴姏寮榪欎釜鍚嶈瘝錛屾斁寮浜嗚錛屽氨鏄笇鏈涚敤鎴瘋兘澶熷垎嫻侊紝涔熷氨鏄鎶婃墍鏈夌敤鎴風殑璁塊棶鍘嬪姏鍒嗘暎鍒板鍙版湇鍔″櫒涓婏紝涔熷彲浠?/p>

鍒嗘暎鍒板涓猼omcat閲岋紝濡傛灉涓鍙版湇鍔″櫒瑁呭涓猼omcat錛岄偅涔堝嵆浣挎槸璐熻澆鍧囪 錛屾ц兘涔熸彁楂樹笉浜嗗お澶氾紝涓嶈繃鍙互鎻愰珮紼沖畾鎬э紝鍗沖閿欐с?/p>

褰撳叾涓竴涓富tomcat褰撴帀錛屽叾浠栫殑tomcat涔熷彲浠ヨˉ涓婏紝鍥犱負tomcat涔嬮棿瀹炵幇浜哠ession鍏變韓銆傚緟tomcat鏈嶅姟鍣ㄤ慨澶嶅悗鍐嶆鍚姩錛屽氨浼?/p>

鑷姩鎷瘋礉鎵鏈塻ession鏁版嵁錛岀劧鍚庡姞鍏ラ泦緹ゃ傝繖鏍峰氨鍙互涓嶉棿鏂殑鎻愪緵鏈嶅姟銆傚鏋滆鐪熸浠庢湰璐ㄤ笂鎻愬崌鎬ц兘錛屽繀欏昏鍒嗗竷鍒板鍙版湇鍔″櫒銆?/p>

鍚屾牱tomcat涔熷彲浠ュ仛鍒般傜綉涓婄浉鍏寵祫鏂欐瘮杈冨錛屽彲浠ュ緢鏂逛究鐨勬煡鍒幫紝浣嗘槸璐ㄩ噺涓嶇畻楂樸傛垜甯屾湜鍙互閫氳繃榪欑瘒闅忕瑪錛岀郴緇熺殑鎬葷粨銆傛湰鏂囩殑

渚嬪瓙鏄悓涓鍙版湇鍔″櫒涓婅繍琛屼袱涓猼omcat錛屽仛涓や釜tomcat涔嬮棿鐨勮礋杞藉潎琛°傚叾瀹炲鍙版湇鍔″櫒鍚勯厤緗竴涓猼omcat涔熷彲浠ワ紝鑰屼笖閭f牱鐨勮瘽錛屽彲浠ヤ嬌鐢?/p>

瀹夎鐗堢殑tomcat錛岃屼笉鐢ㄦ槸涓嬫枃涓殑鍏嶅畨瑁呯殑tomcat錛岃屼笖tomcat绔彛閰嶇疆涔熷氨涓嶇敤淇敼浜嗐備笅鏂囦篃浼氭彁鍒般?/p>

 

               tomcat鐨勮礋杞藉潎琛¢渶瑕乤pache鏈嶅姟鍣ㄧ殑鍔犲叆鏉ュ疄鐜般傚湪榪涜閰嶇疆涔嬪墠璇峰厛鍗歌澆璋冨凡瀹夎鐨則omcat錛岀劧鍚庢鏌pache鐨勭増鏈?/p>

鎴戣繖嬈¢厤緗嬌鐢ㄧ殑鏄痑pache-tomcat-6.0.18鍏嶅畨瑁呯増鏈紝鎴戜翰鑷祴璇曞悗鎺ㄦ柇瀹夎鐗堢殑tomcat鍦ㄥ悓涓鍙版満瀛愪笂浼氫笉鑳藉惎鍔ㄤ袱涓互涓婏紝鍙兘鏄?/p>

鍥犱負瀹夎鐗堢殑tomcat渚靛叆浜嗙郴緇燂紝瀵艱嚧鍗充嬌鍦╯erver.xml閲屼慨鏀逛簡閰嶇疆錛岃繕鏄細寮曡搗鍐茬獊銆傛墍浠ユ垜浣跨敤tomcat鍏嶅畨瑁呯増銆?/p>

apache浣跨敤鐨勬槸apache_2.2.11-win32-x86-no_ssl.msi銆傚鏋滅増鏈綆浜?.2璐熻澆鍧囪 鐨勯厤緗鏈夋墍涓嶅悓錛屽洜涓鴻繖涓?.2.11鍜?.2.8鐗堟湰

闆嗘垚浜唈k2絳夎礋杞藉潎琛″伐鍏鳳紝鎵浠ラ厤緗綆鍗曡澶氥傚埆鐨勭増鏈垜娌℃湁鍏蜂綋嫻嬭瘯錛屾湁寰呰冪┒銆傝繖涓や釜杞歡鍙互鍒板畼鏂圭綉绔欎笅杞姐?/p>

 

                 鎶夾pache瀹夎涓鴻繍琛屽湪80绔彛鐨刉indows鏈嶅姟錛屽畨瑁呮垚鍔熷悗鍦ㄧ郴緇熸湇鍔″垪琛ㄤ腑鍙互鐪嬪埌Apache2.2鏈嶅姟銆傛湇鍔″惎鍔ㄥ悗鍦ㄦ祻瑙堝櫒涓?/p>

杈撳叆http://localhost榪涜嫻嬭瘯錛屽鏋滆兘鐪嬪埌涓涓?It works!"鐨勯〉闈㈠氨浠h〃Apache宸茬粡姝e父宸ヤ綔浜嗐傛妸tomcat瑙e帇鍒頒換鎰忕洰褰曪紝璧嬪間竴涓彟鍛藉悕銆?/p>

璧峰悕鍜岃礬寰勫閰嶇疆娌℃湁褰卞搷銆備絾瑕佷繚璇佺鍙d笉瑕佸啿紿侊紝濡傛灉瑁呮湁Oracle鎴朓IS鐨勭敤鎴烽渶瑕佷慨鏀規(guī)垨鍏抽棴鐩稿叧鎺ュ彛鐨勬湇鍔°傚綋鐒秊dk鐨勯厤緗篃鏄?/p>

蹇呴』鐨勶紝榪欎釜涓嶅啀榪囧鍙欒堪銆?/p>

     

                 棣栧厛錛屽湪Apache瀹夎鐩綍涓嬫壘鍒癱onf/httpd.conf鏂囦歡,鍘繪帀浠ヤ笅鏂囨湰鍓嶇殑娉ㄩ噴絎︼紙#錛変互渚胯Apache鍦ㄥ惎鍔ㄦ椂鑷姩鍔犺澆浠g悊錛坧roxy錛?/p>

妯″潡銆?/p>

 

    LoadModule proxy_module modules/mod_proxy.so
     LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
     LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
     LoadModule proxy_connect_module modules/mod_proxy_connect.so
     LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
     LoadModule proxy_http_module modules/mod_proxy_http.so

 

鍚戜笅鎷夊姩鏂囨。鎵懼埌<IfModule dir_module>鑺傜偣錛屽湪DirectoryIndex index.html鍚庡姞涓奿ndex.jsp錛岃繖涓姝ュ彧鏄負浜嗗緟浼氶厤緗畬tomcat鍚庤兘鐪嬪埌灝?/p>

鐚欏碉紝鍙互涓嶅仛銆傜戶緇笅鎷夋枃妗f壘鍒癐nclude conf/extra/httpd-vhosts.conf錛屽幓鎺夊墠闈㈢殑娉ㄩ噴絎︺?/p>

 

鐒跺悗鎵撳紑conf/extra/httpd-vhosts.conf錛岄厤緗櫄鎷熺珯鐐癸紝鍦ㄦ渶涓嬮潰鍔犱笂

 

澶嶅埗浠g爜
<VirtualHost *:80> 
         ServerAdmin 綆$悊鍛橀偖綆?br />           ServerName localhost
         ServerAlias localhost 
         ProxyPass / balancer://sy/ stickysession=jsessionid nofailover=On 
         ProxyPassReverse / balancer://sy/ 
         ErrorLog "logs/sy-error.log"
         CustomLog "logs/sy-access.log" common
</VirtualHost>

澶嶅埗浠g爜

 

鐒跺悗鍥炲埌httpd.conf錛屽湪鏂囨。鏈涓嬮潰鍔犱笂

 

ProxyRequests Off 
<proxy balancer://sy> 
       BalancerMember ajp://127.0.0.1:8009 loadfactor=1 route=jvm1
       BalancerMember ajp://127.0.0.1:9009 loadfactor=1 route=jvm2
</proxy>

 

ProxyRequests Off 鏄憡璇堿pache闇瑕佷嬌鐢ㄥ弽鍚戜唬鐞嗭紝ip鍦板潃鍜岀鍙e敮涓紜畾浜唗omcat鑺傜偣鍜岄厤緗殑ajp鎺ュ彈绔彛銆俵oadfactor鏄礋杞藉洜瀛愶紝

Apache浼氭寜璐熻澆鍥犲瓙鐨勬瘮渚嬪悜鍚庣tomcat鑺傜偣杞彂璇鋒眰錛岃礋杞藉洜瀛愯秺澶э紝瀵瑰簲鐨則omcat鏈嶅姟鍣ㄥ氨浼氬鐞嗚秺澶氱殑璇鋒眰錛屽涓や釜tomcat閮?/p>

鏄?錛孉pache灝辨寜1錛?鐨勬瘮渚嬭漿鍙戯紝濡傛灉鏄?鍜?灝辨寜2錛?鐨勬瘮渚嬭漿鍙戙傝繖鏍峰氨鍙互浣塊厤緗洿鐏墊椿錛屼緥濡傚彲浠ョ粰鎬ц兘濂界殑鏈嶅姟鍣ㄥ鍔犲鐞?/p>

宸ヤ綔鐨勬瘮渚嬶紝濡傛灉閲囧彇澶氬彴鏈嶅姟鍣紝鍙渶瑕佷慨鏀筰p鍦板潃鍜岀鍙e氨鍙互浜嗐俽oute鍙傛暟瀵瑰簲鍚庣畫tomcat閰嶇疆涓殑寮曟搸璺緞錛坖vmRoute錛夈?/p>

                 濡傛灉浠呬粎涓轟簡閰嶇疆涓涓彲鐢ㄧ殑闆嗙兢錛孴omcat鐨勯厤緗皢浼氶潪甯哥畝鍗曘傚垎鍒墦寮涓や釜tomcat鐨剆erver.xml閰嶇疆鏂囦歡錛屽叾涓竴鍙板彲浠ラ噰鐢ㄩ粯璁?/p>

鐨勮緗紝鍙渶瑕佷慨鏀逛袱涓湴鏂癸紝鑰屽彟涓涓鏈夎緝澶ф敼鍔ㄤ互閬垮厤涓庡墠涓鍙板啿紿併傚鏋滀袱鍙頒笉鍦ㄥ悓涓鍙版湇鍔″櫒涓婅繍琛岋紝瀵逛簬绔彛灝變笉闇鍋氭敼鍔ㄣ傞鍏堟槸

閰嶇疆鍏抽棴绔彛錛屾壘鍒?lt;Server port="8005" shutdown="SHUTDOWN">錛岀涓鍙頒笉鍙橈紝鎶婄浜屽彴鏀逛負9005銆?/p>

                涓嬮潰閰嶇疆Connector鐨勭鍙o紝鎵懼埌non-SSL HTTP/1.1 Connector錛屽嵆tomcat鍗曠嫭宸ヤ綔鏃剁殑榛樿Connector錛屼繚鐣欑涓鍙伴粯璁ら厤緗紝鍦?080绔?/p>

鍙d睛鍚紝鑰屾妸絎簩鍙拌緗負鍦?080绔彛渚﹀惉銆傚線涓嬫壘鍒癆JP 1.3 Connector錛?lt;Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />錛岃繖鏄?/p>

tomcat鎺ユ敹浠嶢pache榪囨潵鐨刟jp榪炴帴璇鋒眰鏃朵嬌鐢ㄧ殑绔彛錛屼繚鐣欑涓鍙伴粯璁よ緗紝鎶婄浜屽彴绔彛鏀逛負9009銆傜涓鍙皌omcat鐨剆erver.xml涓壘鍒?/p>

<Engine name="Catalina" defaultHost="localhost">錛屽幓鎺夎繖孌墊垨鏀逛負娉ㄩ噴錛屾妸涓婃柟绱ф尐鐨?lt;Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">

娉ㄩ噴絎﹀幓鎺夛紝瀵逛簬絎簩鍙幫紝鍘繪帀娉ㄩ噴絎﹀茍鎶妀vm1鏀逛負jvm2銆?/p>

               鍚戜笅鎵懼埌<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>錛屽幓鎺夋敞閲婏紝榪欓噷鐨勯厤緗槸涓轟簡鍙互鍦ㄩ泦緹や腑鐨勬墍鏈塼omcat鑺傜偣

闂村叡浜細璇濓紙Session錛夈傚鏋滀粎浠呬負浜嗚幏寰椾竴涓彲鐢ㄧ殑tomcat闆嗙兢錛孋luster鍙渶瑕佽繖涔堥厤緗氨鍙互浜嗐?/p>

               鍙渶瑕佺畝鍗曠殑鍑犳灝遍厤緗畬鎴愶紝鐒跺悗鍙互嫻嬭瘯涓涓嬫槸鍚﹂厤緗垚鍔熴傚紩鐢ㄧ綉涓婄殑涓涓祴璇曟柟娉曪紝灝辨槸鍦╳ebapps鐩綍涓嬫柊寤簍est鐩綍錛屽湪test鐩?/p>

褰曚笅鏂板緩test.jsp鏂囦歡錛屼唬鐮佹垜紼嶄綔鏀瑰姩濡備笅錛?/p>

 

澶嶅埗浠g爜
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.util.*" %>
<html><head><title>shiyang</title></head>
<body>
鏈嶅姟淇℃伅:
<%
out.println(request.getLocalAddr() 
+ " : " + request.getLocalPort()+"<br/>");%>
<%
out.println(
"<br> ID " + session.getId()+"<br/>"); 
String dataName = request.getParameter("dataName");

if (dataName != null && dataName.length() > 0) {
String dataValue = request.getParameter("dataValue");
session.setAttribute(dataName, dataValue);
}

out.print(
"<b>Session 鍒楄〃</b><br/>");
Enumeration e 
= session.getAttributeNames();

while (e.hasMoreElements()) {
String name = (String)e.nextElement();
String value = session.getAttribute(name).toString();
out.println( name 
+ " = " + value+"<br/>");
System.out.println( name 
+ " = " + value);
}
%>
<form action="test.jsp" method="POST">
鍚嶇О:
<input type=text size=20 name="dataName">
<br/>
鍊?
<input type=text size=20 name="dataValue">
<br/>
<input type=submit value="鎻愪氦">
</form>
</body>
</html>
澶嶅埗浠g爜

 

鍦╰est鐩綍涓嬬戶緇柊寤篧EB-INF鐩綍鍜寃eb.xml錛屽湪<web-app>鑺傜偣涓嬪姞鍏?lt;distributable />錛岃繖涓姝ラ潪甯擱噸瑕侊紝鏄負浜嗛氱煡tomcat鏈嶅姟鍣紝

褰撳墠搴旂敤闇瑕佸湪闆嗙兢涓殑鎵鏈夎妭鐐歸棿瀹炵幇Session鍏變韓銆傚鏋渢omcat涓殑鎵鏈夊簲鐢ㄩ兘闇瑕丼ession鍏變韓錛屼篃鍙互鎶奵onf/context.xml涓殑

<Context>鏀逛負<Context distributable="true">錛岃繖鏍峰氨涓嶉渶瀵規(guī)墍鏈夊簲鐢ㄧ殑web.xml鍐嶈繘琛屽崟鐙厤緗傛祴璇曚唬鐮佸畬鎴愶紒

 

鍏堝惎鍔ˋpache鏈嶅姟錛屽湪鍏堝悗鍚姩涓ゅ彴tomcat錛屽垎鍒偣startup.bat鎵瑰鐞嗐傚鏋滀竴鍒囬『鍒╃殑璇濓紝灝變細鍚姩鎴愬姛銆傚啀嬈¤闂?a href="http://localhost/">http://localhost錛?/p>

鍙互鐪嬪埌灝忕尗欏甸潰銆傝闂?a href="http://localhost/test/test.jsp">http://localhost/test/test.jsp銆傚彲浠ョ湅鍒板寘鎷湇鍔″櫒鍦板潃錛岀鍙o紝session絳変俊鎭湪鍐呯殑欏甸潰銆?/p>

                鐒跺悗浣犲彲浠ユ祴璇曚竴涓嬪閿欏姛鑳斤紝鍏抽棴涓涓猼omcat錛岀湅鐪嬫湇鍔℃槸鍚︽甯革紝鐒跺悗閲嶅惎tomcat錛屽叧鎺夊彟涓鍙皌omcat錛岀湅鐪?/p>

鏄惁涔熷彲浠ョ戶緇彁渚涙湇鍔°傚綋鐒朵綘涔熷彲浠ラ厤緗鍙皌omcat錛屼絾鏄師鐞嗛兘涓鏍楓?/p>

 OK錛岃鍒拌繖閲屻?/p>



gdufo 2012-06-02 08:54 鍙戣〃璇勮
]]>
jmeter嫻嬭瘯zkosshttp://www.tkk7.com/gdufo/archive/2012/05/31/379700.htmlgdufogdufoThu, 31 May 2012 15:35:00 GMThttp://www.tkk7.com/gdufo/archive/2012/05/31/379700.htmlhttp://books.zkoss.org/wiki/Small_Talks/2012/May/Perform_stress_test_on_ZK_using_JMeter-take_Shopping_Cart_as_an_example

Contents

[hide]

Preface

Dennis Chen has shared a small talk illustrating how you can execute a loading test with ZK applications using JMeter. Now, in this small talk we will take a real application as an example to demonstrate in detail how you can actually apply the ideas illustrated in Dennis’ article to perform a stress test.

Test plan

We will be using the "shopping cart" example from ZK Essentials as the template application to perform the stress test.

Setup

  • ZK 5.0.11
  • zk testing demo ( a demo based on the shopping cart sample)
  • Jmeter 2.5.1

Test Scenario

  1. User enters his user name and password for authentication
  2. Login successfully to the shopping site, redirect to index.zul
  3. User selects an item and drag to the shopping cart
  4. User checks out

Since this is a stress test, we can apply 50, 100, 150,... concurrent users to perform the test scenario simultaneously. In our example we have created a max of 300 accounts, which allows you to perform the test with as many as 300 concurrent users.

Before we start

As mentioned above we will be using the "shopping cart" example from ZK Essentials as the template application. However there is only one set of login/password in the current shopping cart implementation which is not sufficient for multiple users. To support multiple users, we have modified the shopping cart example to generate multiple accounts, so that each user will be logged in using a different account. This is done as follows, and it will be triggered as you click "createUserBtn" in login.zul:

1. prepare a CSV file that includes a list of user names and passwords:

Csv.png

2. Add the following code to LoginViewCtrl.java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public void onClick$createUserBtn() {
        Map map = userinfo();
        Session session = StoreHibernateUtil.openSession();
        Transaction t = session.beginTransaction();
         
        Iterator entries = map.entrySet().iterator();
        int i = 0;
        while (entries.hasNext()) {
            i ++;
            Map.Entry entry = (Map.Entry) entries.next();
            String name = (String)entry.getKey();
            String pwd = (String)entry.getValue();
            User user = new User(i, name, pwd, "user");
            session.save(user);
            if (i % 20 == 0) {
                session.flush();
                session.clear();
            }
        }
        t.commit();
        session.close();
    }

Configuring ZK

As illustrated in Dennis’ small talk, you need to define IdGenerator to fix the desktop IDs and component IDs so that we can record and play the testing script. The IdGenerator is implemented as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
public class MyIdgenerator implements IdGenerator {
    private static ThreadLocal<HttpServletResponse> response = new ThreadLocal<HttpServletResponse>();
    private static AtomicInteger ai = new AtomicInteger();
 
    public String nextComponentUuid(Desktop desktop, Component comp) {
        String number;
        if ((number = (String) desktop.getAttribute("Id_Num")) == null) {
            number = "0";
            desktop.setAttribute("Id_Num", number);
        }
        int i = Integer.parseInt(number);
        i++;// Start from 1
        desktop.setAttribute("Id_Num", String.valueOf(i));
        return "t_" + i;
    }
 
    public String nextDesktopId(Desktop desktop) {
        HttpServletRequest req = (HttpServletRequest)Executions.getCurrent().getNativeRequest();
        String dtid = req.getParameter("tdtid");
        if(dtid!=null){
        }
        return dtid==null?null:dtid;
    }
 
    public String nextPageUuid(Page page) {
        return null;
    }
}
  • Define your IdGenerator in zk.xml

Then, define your IdGenerator in zk.xml, for example,

1
2
3
<system-config>
        <id-generator-class>foo.MyIdgenerator</id-generator-class>
</system-config>

Preparing Testing Scripts

Now we are ready to record the scripts. We will be recording 6 HTTP requests as illustrated in the image below. What we need to do is to configure the parameters of these 6 requests based on the application that we wish to test.

All.png

Load CSV file as the variable of the user name and password

  • Add a CSV Data Set Config

First we need to add a CSV Data Set Config here. The element will iterate the csv data set to simulate muti-users login into the application. Please specify a fully qualified name to the Filename field (ex: C:\mycsv\users.csv ), and specify the variable name to the Variable Names field for later use.

Csv data set.png

  • Add BSF PostProcessor

Then we need to ask jmeter to generate the accounts and passwords automatically based on our CSV file. What we need to do is to add a BSF PostProcessor element, set the language to beanshell, and define:


var username = vars.get("username");

var password = vars.get("password");

vars.put("user","{\"value\":\""+username+"\",\"start\":2}");

vars.put("pwd","{\"value\":\""+password+"\",\"start\":2}");


This script will get the username and password variables generated by CSV Data Set Config element, and combine the result and some text as a parameter which will be used as user names and passwords later.

BSF PostProcessor.png

Set account & password as variables

With these settings ready, we can now set the parameter dtid as ${dtid} and use EL to replace a fixed account and password in the first ajax request (i.e. the login request). For example if we send zk/zk as user name and password, then we will be seeing

data_3: {"value":"zk","start":2} //for username

data_4: {"value":"zk","start":2} //for password

in the recorded jmeter’s request. Then, we use ${user} and ${pwd} to replace {"value":"zk","start":2} for handling the accounts and passwords dynamically.

Submit.png

Generate new desktop ID for redirecting to a new page

After an user logged into the system, he will be redirected to index.zul. Since the URL is changed, the desktop and it’s id will also be changed, we need to retrieve the desktop id again using ${__intSum(${dtid},1,dtid)}.

Specify parameter

The last 3 http requests are for adding products to the shopping cart, check out, and close the browser tab. What we need to do is just to modify their tdtid to ${__intSum(${dtid},1,dtid).

DTID.png

Add the listeners for creating reports

There are many different elements that allows you to generate different kinds of reports, such as Aggregate Report and Graph Results. You can add these listeners to Thread Group or HTTP request depending on the report you wish to generate.

Listener1.png

Now we have completed all the settings and have saved these configurations as test.jmx.

Running the test

Now we are ready to start the application and to run the test.

  1. Generate accounts
  2. Start your web server, and access login.zul. Click createUserBtn for creating multiple accounts.

    CreateAccounts.png

  3. Run the testing script
    1. Open jmeter’s menu, File > Open , and load test.jmx.
    2. Specify your IP and port, for example we use localhost/8080 as ip and port number
    3. Http request default.png

    4. In Thread Group ( the root element), set the number of concurrent users to test.
    5. Set number of Users .png

    6. Perform Run > Start to run the test.
    7. You can then observe the average response time, 90% line response time, median response time and other results by accessing the Aggregate Report .

      Aggregate report.png

Trouble-shooting & Tips

  1. Tips: Performing repeating tests
  2. If you have finished a round of test (for example 0~50) you should restart your server before performing another round of test. This is because after you finish a round of test, there will be an extra item listed in each user’s page because they all ordered an item. This extra item is displayed at the bottom of the page (see the image on the right). As there is a DOM change due to this extra item, components’ IDs and orders are also changed thus different from the script you recorded earlier. To solve this problem, just restart your server before performing another round of test.

    Without order.png One order.png

  3. Trouble-shooting: Erred response
  4. Nothing response.png

    If you encounter the Response data error shown as the image above, it is most likely that you did not implement IdGenerator correctly. Please refer to Configuring ZK section to implement UUID.

  5. Trouble-shooting: Timeout error
  6. Timeout.png

    Timeout errors occur when the desktop id in the Ajax request is no longer available at the server side. This normally happens when the URL is changed. If this happens, you need to retrieve desktop ID again. Please refer to Testing Scripts section to implement Desktop ID.

    Timeout may also relate to the max allowed desktops. In ZK there is a setting called “max-desktops-per-session” which defines the max concurrent desktops for each session. The more browser tabs an user opens the more desktops will be saved on the session. If the number exceeds the max allowed desktops then some desktops will be dropped with the timeout error.

    By default the number is 15 which means an user can open as many as 15 tabs in a same browser at the same time. If you have configured it to a smaller number for saving the memory, and in your use case the users will be opening up multiple tabs then you should double check whether this is the reason causing the timeout error. To change this setting, use:

    1
    2
    3
    <session-config>
        <max-desktops-per-session>1</max-desktops-per-session>
    </session-config>
  7. Tips: close browser tab for saving memory
  8. ZK stores desktops in sessions, when user closes the browser tab ZK will send the rmDesktop command to remove the desktop. We can simulate this behavior to save memory when performing a stress test. This is done in the last http request defined in test.jmx. You can refer to the image below:

    RmDesktop.png

Downloads

users.csv - users.csv (Please place the csv file under C:/mycsv/)

zk testing demo – the modified shopping cart application used in this small talk

jmeter 2.5.1 – http://jmeter.apache.org/download_jmeter.cgi

test.jmx – test.jmx




gdufo 2012-05-31 23:35 鍙戣〃璇勮
]]>
Tomcat5.5閰嶇疆-澶氬煙鍚嶇粦瀹氬拰铏氭嫙鐩綍 http://www.tkk7.com/gdufo/archive/2009/01/06/250021.htmlgdufogdufoTue, 06 Jan 2009 00:30:00 GMThttp://www.tkk7.com/gdufo/archive/2009/01/06/250021.htmlhttp://www.tkk7.com/gdufo/comments/250021.htmlhttp://www.tkk7.com/gdufo/archive/2009/01/06/250021.html#Feedback0http://www.tkk7.com/gdufo/comments/commentRss/250021.htmlhttp://www.tkk7.com/gdufo/services/trackbacks/250021.html闃呰鍏ㄦ枃

gdufo 2009-01-06 08:30 鍙戣〃璇勮
]]>
tomcat綆$悊鐣岄潰甯哥敤璁劇疆 -- 涓嶈В鍘媤ar鏂囦歡http://www.tkk7.com/gdufo/archive/2008/07/02/212193.htmlgdufogdufoWed, 02 Jul 2008 12:17:00 GMThttp://www.tkk7.com/gdufo/archive/2008/07/02/212193.html

褰?
1. war鏂囦歡鍐呯殑WEB-INF/classes鐩綍涓嬬殑鎵鏈塩lass鏂囦歡
2. war鏂囦歡鍐呯殑/WEB-INF/lib鐩綍涓嬬殑鎵鏈塲ar鏂囦歡
3. war鏂囦歡鍐呯殑/WEB-INF鐩綍涓嬬殑web.xml鏂囦歡
4. war鏂囦歡鍐呯殑鐜閰嶇疆鏂囦歡
涓婅堪鍥涢」涓殑浠諱竴欏規(guī)敼鍙樺悗鑷姩閲嶈澆銆傝繖鏍峰氨鏃犻』鎵嬪伐閲嶆柊deploy錛岃妭鐪佽皟璇曟椂闂淬?br />
1.鐧婚檰綆$悊鐣岄潰
http://localhost:8080/admin

瀵嗙爜鍜岀敤鎴峰悕鍦ㄤ綘瀹夎鐨勬椂鍊欒瀹氱殑錛屽鏋滃繕璁?鎴栨病鏈?鐨勮瘽錛屽幓鏀箃omcat\conf\tomcat-users.xml錛屾坊鍔燼dmin鍜?manager涓や釜role錛屼竴涓敤鎴鳳紝璇ョ敤鎴風殑role涓篴dmin鍜宮anager灝卞彲浠ヤ簡錛屾寜鍘熸湁鐨剎ml澶嶅埗淇敼灝卞彲浠ャ?br />
2.璁劇疆姝ラ
  2.1 鐐瑰嚮宸﹁竟妗嗘灦涓璖ervice鑿滃崟欏瑰乏杈圭殑灝忓渾錛屽睍寮鍒楄〃 
  2.2 鐐瑰嚮宸﹁竟妗嗘灦涓璈ost (localhost)鑿滃崟欏癸紝鍙寵竟妗嗘灦鍑虹幇璁劇疆欏?br />   2.3 鎶婂彸杈規(guī)鏋朵腑Unpack WARs鍙寵竟鐨勪笅鎷夊垪琛ㄦ敼涓篺alse
  2.4 鐐瑰嚮鍙寵竟妗嗘灦涓彸涓婅save鎸夐挳 
  2.5 鐐瑰嚮欏墮儴妗嗘灦Commit Changes鎸夐挳

娉ㄦ剰錛?span style="color: red">瑕佷繚璇佹枃浠朵笉鏄彧璇葷殑





gdufo 2008-07-02 20:17 鍙戣〃璇勮
]]>
涓嶈兘璁塊棶Tomcat5.5鐨刟dmin欏甸潰 http://www.tkk7.com/gdufo/archive/2008/07/02/212189.htmlgdufogdufoWed, 02 Jul 2008 12:00:00 GMThttp://www.tkk7.com/gdufo/archive/2008/07/02/212189.html
Tomcat 5鍙互閫氳繃浠ヨ繍琛屽湪緗戦〉嫻忚鍣ㄧ殑閰嶇疆搴旂敤紼嬪簭闈炲父鏂逛究鍦拌繘琛屾湇鍔″櫒鐨勯厤緗傝繖涓簲鐢ㄧ▼搴忕О涓篢omcat Administration Web Application銆傜劧鑰岋紝Tomcat 5.5 浠ュ悗鐨刡inary 鏍稿績瀹夎鐗堜笉鍐嶆彁渚汿omcat Administration Web Application銆傝瀹夎鍚庤咃紝闇瑕佸崟鐙笅杞藉拰瀹夎銆俆omcat 騫舵病鏈変負Administration Web Application鎻愪緵涓縐嶈嚜鍔ㄦ暣鍚堢殑瀹夎紼嬪簭銆傛湰鏂囧皢璁茶堪瀹夎鍜岄厤緗殑璇︾粏榪囩▼銆?br />
絎竴姝ワ紝紜浣犵殑Tomcat 涓槸鍚﹀凡瀹夎浜咥dministration Web Application銆傞鍏堢‘瀹歍omcat Service 姝e湪榪愯銆傜劧鍚庡湪嫻忚鍣ㄤ腑錛岄敭鍏?http://localhost:8080/admin錛屽鏋滅湅鍒癟omcat Web Server Administration Tool 鐨勯〉闈紝璇存槑Administration Web Application 宸插畨瑁呭ソ浜嗐備綘鍙互鐪佺偣鏃墮棿錛屼笉蹇呰涓嬫枃浜嗐傚鏋滅湅鍒扮殑鏄?br /> Tomcat's administration web application is no longer installed by default. Download and install the "admin" package to use it.
閭d箞榪欑瘒鏂囩珷灝辯畻浣犵湅瀵逛簡錛屽氨鏄笓闂ㄤ負浣犲啓鐨勩?br />
絎簩姝ワ紝涓嬭澆admin package銆傝瀹炶瘽錛屽緢澶氫漢灞呯劧鎵句笉鍒板湪鍝噷涓嬭澆銆傝繖涓嶆綘浠侫pache Tomcat 鐨勪笅杞介〉闈㈢殑鎸囩ず涓嶆槸寰堟竻妤氾紝褰撶劧鎶鏈枃妗d篃涓嶇敋璇﹀敖銆備絾鏄漢瀹跺凡緇忕粰浣犳彁渚涗簡鍔熻兘寮哄ぇ鐨刼pen source 杞歡錛屼綘榪樿兘鎶辨ㄤ粈涔堝憿錛熻鎬氨鎬殑宸ュか娌′笅鍒幫紝鍔熷か涓嶅娣便?br />
浠旂粏鐪嬶紝http://tomcat.apache.org/download-55.cgi 錛?鍦ㄤ笅杞介〉闈㈢殑Binary Distributions鏍忎笅鐨勭鍥涘ぇ欏癸紝Administration Web Application 鍗蟲槸銆?br />
絎笁姝ワ紝褰撹В鍘嬩笅杞界殑Administration Web Application 鏂囦歡錛屾瘮濡傛斁鍦╟:\tom涓紝浣犱細鍙戠幇瑙e帇鍚庣殑鏂囦歡涓?c:\tom\apache-tomcat-5.5.17銆?榪欐椂閿叆 http://localhost:8080/admin 鍘繪楠宎dmin錛屼細鍙戠幇Tomcat浠涔堥兘娌℃湁鏀瑰彉銆傚洜涓鴻В鍘嬬殑admin鏂囦歡榪樻病鏈夐厤緗埌Tomcat 鐨勭郴緇熶腑銆備笅闈㈢殑姝ラ鍛婅瘔浣犲浣曞皢admin鏂囦歡閰嶇疆鍒癟omcat 鐨勬湇鍔″櫒涓?br />
絎洓姝ワ紝灝?c:\tom\apache-tomcat-5.5.17\conf\Catalina\localhost\admin.xml鐨?br /> admin.xml 鏂囦歡鎷瘋礉鍒癱:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\Catalina\localhost. 鐨勬枃浠跺す涓傛敞鎰忎竴瀹氳鏀懼湪姝g‘鐨勮礬寰勭殑鏂囦歡澶逛腑銆?br />
絎簲姝ワ紝灝哻:\tom\apache-tomcat-5.5.17\server\webapps涓殑admin鏁翠釜鏂囦歡澶規(guī)嫹璐濆埌c:\Program Files\Apache SoftwareFoundation\Tomcat5.5\server\webapps 鏂囦歡澶逛腑銆?br />
絎叚姝ワ紝鐢ㄥ叿鏈夌紪杈戝姛鑳界殑notepad絳夋墦寮 c:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\涓殑tomcat-users.xml 鏂囦歡銆傚湪</tomcat-user>鏈鍚庝竴琛屼箣鍓嶏紝鍔犲叆涓嬪垪涓琛?br />
<user username="admin" password="tomcat" roles="admin,manager"/>

娉ㄦ剰username/password鍙互鏄綘鍠滄鐨勪換鎰忕粍鍚堬紝浣唕oles=”admin” 涓嶅彲闅忔剰鏀瑰姩銆?br />
絎竷姝ワ紝閲嶅惎Tomcat Server錛岀劧鍚庢墦寮http://127.0.0.1錛?080/榪涘叆manager閲岄潰鎶奱dmin鏈嶅姟鍚姩璧鋒潵錛岀劧鍚庡啀榪涘叆admin妯″潡閲岋紝鍦╳eb嫻忚鍣ㄤ腑閿叆 http://localhost:8080/admin錛?榪欐椂浣犲鏋滆兘鐪嬪埌 Tomcat Server Web Administration Tool 鐨刲ogin鐣岄潰錛?灝卞ぇ鍔熷憡鎴愩傝嫢鏄繕鐪嬩笉鍒頒笂榪伴〉闈紝鍙鏌ユ祻瑙堝櫒鐨勪唬鐞嗘湇鍔″櫒鐨勮瀹氾紝浣夸箣鑳藉鎺ュ彈localhost銆?

榪樻墦涓嶅紑灝辯敤涓嬮潰鐨勭粓鏋佺粷鎷涳紒

鐩綍: E:\Tomcat5.5\conf\web.xml
<!-- listings Should directory listings be produced if there -->
<!-- is no welcome file in this directory? [false] -->
<!-- WARNING: Listings for directories with many -->
<!-- entries can be slow and may consume -->
<!-- significant proportions of server resources. -->
<!-- -->
.....
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>
org.apache.catalina.servlets.DefaultServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
......
false --> true
榪欐牱灝卞彲浠ユ祻瑙堜簡錛屼笉榪囨暣涓猅omcat閮芥槸鍙互嫻忚錛屾湁鐐瑰嵄闄┿?br /> 鍏朵粬灝辨寜浣犺嚜宸辯殑閰?
鐩綍:E:\Tomcat5.5\conf\Catalina\localhost\jspweb.xml
<?xml version='1.0' encoding='utf-8'?>
<Context docBase="/c:/jspweb/" path="/jspweb">
</Context>
鍥犺鍜?.0涓鏍蜂簡,涓嶈繃浣犵粷瀵規(guī)槸嫻垂5.5鐨勫畨鍏ㄧ壒鎬?....
鐩綍: E:\Tomcat5.5\conf\web.xml
<!-- listings Should directory listings be produced if there -->
<!-- is no welcome file in this directory? [false] -->
<!-- WARNING: Listings for directories with many -->
<!-- entries can be slow and may consume -->
<!-- significant proportions of server resources. -->
<!-- -->
.....
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>
org.apache.catalina.servlets.DefaultServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
......
false --> true
榪欐牱灝卞彲浠ユ祻瑙堜簡錛屼笉榪囨暣涓猅omcat閮芥槸鍙互嫻忚錛屾湁鐐瑰嵄闄┿?br /> 鍏朵粬灝辨寜浣犺嚜宸辯殑閰?
鐩綍:E:\Tomcat5.5\conf\Catalina\localhost\jspweb.xml
<?xml version='1.0' encoding='utf-8'?>
<Context docBase="/c:/jspweb/" path="/jspweb">
</Context>
鍥犺鍜?.0涓鏍蜂簡,涓嶈繃浣犵粷瀵規(guī)槸嫻垂5.5鐨勫畨鍏ㄧ壒鎬?....

鐩綍: E:\Tomcat5.5\conf\web.xml
<!-- listings Should directory listings be produced if there -->
<!-- is no welcome file in this directory? [false] -->
<!-- WARNING: Listings for directories with many -->
<!-- entries can be slow and may consume -->
<!-- significant proportions of server resources. -->
<!-- -->
.....
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>
org.apache.catalina.servlets.DefaultServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
......
false --> true
榪欐牱灝卞彲浠ユ祻瑙堜簡錛屼笉榪囨暣涓猅omcat閮芥槸鍙互嫻忚錛屾湁鐐瑰嵄闄┿?br /> 鍏朵粬灝辨寜浣犺嚜宸辯殑閰?
鐩綍:E:\Tomcat5.5\conf\Catalina\localhost\jspweb.xml
<?xml version='1.0' encoding='utf-8'?>
<Context docBase="/c:/jspweb/" path="/jspweb">
</Context>
鍥犺鍜?.0涓鏍蜂簡,涓嶈繃浣犵粷瀵規(guī)槸嫻垂5.5鐨勫畨鍏ㄧ壒鎬?....



gdufo 2008-07-02 20:00 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 免费在线看v网址| 一级成人毛片免费观看| 亚洲日本国产综合高清| 色网站在线免费观看| 国产三级在线免费| 日本免费的一级v一片| 人人狠狠综合久久亚洲婷婷| 亚洲中文无码亚洲人成影院| 国产一级婬片A视频免费观看| 波多野结衣在线免费视频| 亚洲精品无码av天堂| 亚洲欧洲日韩综合| 精品久久久久久国产免费了 | 亚洲美女视频免费| 亚洲?v女人的天堂在线观看| 亚洲色偷偷偷网站色偷一区| 国产福利电影一区二区三区,免费久久久久久久精 | 亚洲国产午夜精品理论片| 特级毛片免费观看视频| 亚洲国产成人久久综合野外| 亚洲偷自拍另类图片二区| 国产免费无遮挡精品视频| 亚洲国产成a人v在线观看 | 曰批全过程免费视频观看免费软件| 91黑丝国产线观看免费 | 未满十八私人高清免费影院| 好大好硬好爽免费视频| 亚洲自偷自偷精品| 免费福利电影在线观看| 亚洲国产中文在线二区三区免| 免费黄色网址入口| 亚洲一区二区三区不卡在线播放 | 亚洲熟妇av一区| 污视频在线观看免费| 人人狠狠综合久久亚洲婷婷| 亚洲无砖砖区免费| 高h视频在线免费观看| 亚洲AV无码专区国产乱码4SE| 久久久久国色AV免费观看| 亚洲色成人网一二三区| 国产免费变态视频网址网站 |