]X2a,aJ]x O0最近在对Tomcat服务器的web应用进行性能测试的过程中,有时LoadRunner中总会报错:
/@?9GA6W:jr0Action.c(71): Error -27791: Server "localhost" has shut down the connection prematurely51Testing软件测试网%h4ZTE"qHQW0o
但是这个错误并不是每次测试都会出现,通常在长时间的测试之后才偶尔出现,而奇怪的是在Tomcat的日志中并没有相应的错误。从出错信息的字面信息来看,应该是服务器由于某些原因关闭了连接,而Tomcat并不认为这是一个错误,因此没有在日志中记录下来。在网上的搜索中看到,这个错误在其他的服务器如WebLogic、IIS等均有发生,看来是一个通用的问题。51Testing软件测试网+} g y q'fZpK

a0pC4~D3x}%pH"t0在诊断的过程中,发现Tomcat运行界面有时会提示:“严重: All threads (10) are currently busy, waiting. Increase maxThreads (10) or check the servlet status”,根据这一线索对Tomcat的server.xml中的maxThreads、connectionTimeout参数进行配置,解决了这个问题。51Testing软件测试网9] Ooih

51Testing软件测试网"YR+HX L6qu;V0Q:q

试验51Testing软件测试网8k'J DD k5D&aED
为了验证这两个参数对测试结果的影响,我做了一些试验。
+A(o3M,d(kC y3a0测试场景:一个测试脚本、20个虚拟用户、10次迭代51Testing软件测试网DJ ?&[u.x3G
参数设置及相应运行结果: 

Vy~ h:\y U.t0

3]sO7JHP3p0

maxThreads

+s$_4p5H2j:wSB0

connectionTimeout(豪秒)51Testing软件测试网\Zxu%?C

错误个数51Testing软件测试网,jo/u+\QVlW

551Testing软件测试网U(S&~[ ej6m R"p9T

1000

hL:oDT0

1651Testing软件测试网|PfJU&l

10

%p~k(qt h)dH.] n y0

1000

,_w:p*b_iL7ev'R0

13

-F+b R%^6C^6Cp0

15

,~Y9~(~-TR.On,Rdl0

100051Testing软件测试网p8H El#`-nB {)o

751Testing软件测试网WU(W~ ~.dA

2051Testing软件测试网`U4f2M@I3I

100051Testing软件测试网|s L.V.?.k

051Testing软件测试网 mvlW"J0A

551Testing软件测试网+`A.m4p^ W&l

10000

+Zx*Sz_Q;G0

151Testing软件测试网#p8J4U+P}i

10

]']eB X,t&{(i0

1000051Testing软件测试网"oL4A,R!a|(MO/q

0

7AZkEuy6bKJ-p0

1551Testing软件测试网)H0C-qq,A5\3@

10000

/f[A3WEG?}cs0

0

{;SQ:Bc0

20

a&s5A@;XZ$hK[R0

1000051Testing软件测试网(OEbo3^g7Pp

051Testing软件测试网"E$qo`3r H

Ni#?}/I q'e*q0

up7g,S2kag)Q$O0试验结论
q$Af.P` Q/YE0当最大线程数较少、超时时间较短时,出现这个错误的次数就越多;随着最大线程数逐步接近并发用户数,该错误逐渐减少。另外,延长超时时间也能够减少错误的出现,但这时由于请求在处于排队状态,因此会增加响应时间。51Testing软件测试网j"L'?H{(\`

E7nq5|1r5K6b6t0引申
_EqyPbkmM!iU0?0
将该结果应用于性能调优中,在一定的负载压力下,增加最大线程数能够有效的提高服务器的并发处理能力,但前提是系统资源如CPU、内存等不会成为系统瓶颈,在不能再提高最大线程数时,也可以用增加超时时间的方法,但这会造成响应时间的增加。参数最佳设置根据具体应用和测试结果而定。在有条件的情况下,最好就是集群了。51Testing软件测试网Q7k7J%]%AP,~$zM
51Testing软件测试网:@;C R-Y vKQ
附:51Testing软件测试网 t{$P'Oj _.c+J rJV
当以上错误出现在用到web_reg_save_param函数的响应中时,会伴随着其他错误:51Testing软件测试网6A&rM_'`EG:h8d1T/j
Action.c(248): Error -26377: No match found for the requested parameter "ClientID". Check whether the requested boundaries exist in the response data. Also, if the data you want to save exceeds 10240 bytes, use web_set_max_html_param_len to increase the parameter size
Hg.b#Zx5]Sm0Action.c(248): Error -26374: The above "not found" error(s) may be explained by header and body byte counts being 0 and 0, respectively.

l.O#y:\7V-TS)c0