Tomcat性能测试

来源:互联网 发布:武汉淘宝天猫培训机构 编辑:程序博客网 时间:2024/06/11 16:42

测试环境

  • OS: Linux Red Hat 4.4.7-11
  • Memery: 16G
  • CPU: 4 Processor(Intel(R) Xeon(R))
  • JDK:1.8
  • Web服务器r: Tomcat 7.x
  • 测试工具: Jmeter-2.9
  • Monitor Tools: jconsole,jvisualvm,jstat

Prepare

 Run a simple servlet  at the Server container,as exclude Application delay,It just return a echo word.


Reference

  • Cient Thread: Mock User Request
  • Average: Response Time,unit:ms
  • Throughput: Query per Second,The formula is: Throughput = (number of requests) / (total time).
  • Maxthreads:The maximum num of connections that the server will accept and process.

Case 1

Server parameters as default

maxThread: 200

Client ThreadAverage 
Throughput 
load average 
100230 
422 
<15003171545<1 
10003822415<1 
15003269197<1

As the table shows,The Throughput increase  with the client's increase.But it decrease obviousely when client num over 1000.

Check the server,we can see every work thread is busy


Case 2

maxThread:  500

Client Thread
Average
Throughput
load average
5002571935<310003223086<3 
15004173458<3 
20005842815<3 
30008862487<3 

Case 3

maxThread: 5000

Client Thread
Average
Throughput
load average
100217450<25002192240<2 
1000310105<2 

When the client over 1000,The Client Http tools appear many error logs,It shows "client  Non HTTP response message: Read timed out",

check the tomcat log to get the error:

java.lang.OutOfMemoryError: unable to create new native thread  
    at java.lang.Thread.start0(Native Method)  
    at java.lang.Thread.start(Thread.java:691)  
    at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:949)  
    at java.util.concurrent.ThreadPoolExecutor.processWorkerExit(ThreadPoolExecutor.java:1017)  
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1163)  
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
    at java.lang.Thread.run(Thread.java:722)  

It shows The maxTheads number  exceed the limiting  Number of Processes Available,The CentOs  max user processes default is 1024,update the param 
 at file /etc/security/limits.d/90-nproc.conf as following,

*  soft   nofile 65536

*  hard   nofile 65536

*  soft   nproc  10240

*  hard   nproc  10240

Case 4

continue the test,

maxThread: 5000

Client Thread
Average
Throughput
load average
5001982171<310001994087<3 
15002115106<3 
20002205820<3 

Case 5

1.update the JVM options 

JAVA_OPTS="$JAVA_OPTS -Xms3g -Xmx5g -Xss512K -XX:PermSize=256m -XX:MaxPermSize=512m "

2.maxThread: 5000

Client Thread
Average
Throughput
maxThreads
load average
500 
2016926 
5000 
3.61000 
22081225000 
4.021500 
34882385000 
4.3200044678695000 
8.2

Now,Check the  JVM,


It seam there's enought Memory,and The GC frequency is not hight,So exclude the VM Memory factor, And As the case 5 shows,

Load is over the CPU max load,It have arrive the bottleneck of system.