Configuration: Intel Xeon E5 2.4g*6 Core, 16G memory, Redhat Linux x64,jdk 7 (server), Tomcat 8.9
Changed the tomcat memory configuration, opened the Nio+epoll, the results are still not good-looking ...
VI bin/catalina.sh
?
12 |
CATALINA_OPTS=‘-Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.EPollSelectorProvider‘ JAVA_OPTS= -Xms800M -Xmx1500M -XX:PermSize=128M -XX:MaxPermSize=300M |
VI Conf/server.xml
?
12345678910 |
<
Connector
port
=
"7080"
protocol
=
"org.apache.coyote.http11.Http11NioProtocol"
connectionTimeout
=
"20000"
redirectPort
=
"7443"
acceptorThreadCount
=
"6"
acceptCount
=
"800"
maxThreads
=
"400"
compression
=
"on"
compressionMinSize
=
"2048"
noCompressionUserAgents
=
"gozilla,traviata"
compressableMimeType
=
"text/html,text/xml,text/javascript,text/css,text/plain"
/>
|
using Jfinal+beetl template,Apache AB pressure test results:
?
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
D:\tools\Apache2.2\bin>ab -n 1000 -c 50 http://192.168.xx.xxx:7080/jfinalBeetl
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 192.168.xx.xxx (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: Apache-Coyote/1.1
Server Hostname: 192.168.xx.xxx
Server Port: 7080
Document Path: /jfinalBeetl
Document Length: 327 bytes
Concurrency Level: 50
Time taken for tests: 0.656 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Non-2xx responses: 1000
Total transferred: 146000 bytes
HTML transferred: 0 bytes
Requests per second: 1523.81 [#/sec] (mean)
Time per request: 32.813 [ms] (mean)
Time per request: 0.656 [ms] (mean, across all concurrent requests)
Transfer rate: 217.26 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 2.6 0 16
Processing: 0 32 6.3 31 47
Waiting: 0 20 11.2 16 47
Total: 0 32 6.4 31 47 Percentage of the requests served within a certain time (ms)
50% 31
66% 31
75% 31
80% 31
90% 47
95% 47
98% 47
99% 47
100% 47 (longest request)
|
Beetl,apache AB test results are not used:
?
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
D:\tools\Apache2.2\bin>ab -n 1000 -c 50 http://192.168.xx.xxx:7080/Root
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 192.168.xx.xxx (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: Apache-Coyote/1.1
Server Hostname: 192.168.xx.xxx
Server Port: 7080
Document Path: /Root
Document Length: 11430 bytes Concurrency Level: 50
Time taken for tests: 1.297 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 11571000 bytes
HTML transferred: 11430000 bytes
Requests per second: 771.08 [#/sec] (mean)
Time per request: 64.844 [ms] (mean)
Time per request: 1.297 [ms] (mean, across all concurrent requests)
Transfer rate: 8713.10 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 4.1 0 16
Processing: 16 62 9.7 63 94
Waiting: 0 29 18.1 31 78
Total: 16 63 9.5 63 94
Percentage of the requests served within a certain time (ms)
50% 63
66% 63
75% 63
80% 63
90% 78
95% 78
98% 78
99% 78
100% 94 (longest request)
|
Hemp, and then improve, estimated to be more than 2000, have listened to a netizen said, tuning after the Tomcat project to 3000, do not know how to do ...
Who's the pro to say ...
The following by the moon according to the Yangtze River users provide:
?
123456789101112131415 |
我看了一下,tomcat给的几个参数,你先别忙着上集群,试试这些,tomcat8
1.Executor 配置
1.1 maxThreads ,默认是200,把这个设置这个数值,可以再高一些。400,800都试试。会有瓶颈。
2.HTTP Connector 设置
2.1 acceptCount 默认是100,调高,翻几倍试试
2.2 acceptorThreadCount 默认是1,调成CPU线程数,比如4核心8线程,就调成8.
2.3 maxThreads 默认是200,调高
2.4 processorCache 如果使用servlet3.0,配置到和 maxThread 一样
任何和缓冲区相关的配置都可以调大。
JVM参数尽量调大,各代配合合适的内存回收算法。
etc
详见:http://tomcat.apache.org/tomcat-8.0-doc/config/http.html
压缩选项之类的可以看着来,其他的比如可以把NIO2改成 APR。
以上是根据官网给的配置信息 “利用丰富的想象力” 得来的答案,没有经过任何测试。
先榨干一个tomcat,再上集群!
|
The following turns from http://blog.csdn.net/lifetragedy/article/details/7708724:
?
123456789 |
Tomcat的优化分成两块: Tomcat启动命令行中的优化参数即JVM优化 Tomcat容器自身参数的优化(这块很像ApacheHttp Server) catalina.sh export JAVA_OPTS=..... -server: 我不管你什么理由,只要你的tomcat是运行在生产环境中的,这个参数必须给我加上 –Xmn: 设置年轻代大小为512m。整个堆大小=年轻代大小 + 年老代大小 + 持久代大小。持久代一般固定大小为64m,所以增大年轻代后,将会减小年老代大小。此值对系统性能影响较大,Sun官方推荐配置为整个堆的3/8。 -Xss: 是指设定每个线程的堆栈大小。这个就要依据你的程序,看一个线程 大约需要占用多少内存,可能会有多少线程同时运行等。一般不易设置超过1M |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
See the official documentation for the specific configuration:
Https://tomcat.apache.org/tomcat-6.0-doc/config/http.html
In fact, the maximum number of connections for Tomcat is the maximum number of threads that Tomcat itself encapsulates for the thread pool. This maximum number of connections may meet your needs, but not necessarily your optimal number.
If your business is computationally intensive:
In compute-intensive applications, the size of the thread pool should be equal to the number of CPUs in the host. Adding more threads will interrupt the processing of the request because the context switch of the thread also delays the response time. In general, if you have 1000 + threads in your process, the CPU will spend a lot of time wasting thread switching. So tomcat defaults to the 200 maximum number of connections is not unreasonable.
Non-blocking IO applications will be CPU intensive because there is no thread waiting time when requests are processed.
If your business is IO-intensive:
Determining the size of the thread pool for an IO wait application becomes more complex due to dependency on the response time of the downstream system, because one thread is always blocked before the other system responds
So it depends on your specific business processing type.
Personal advice: For the number of concurrent requirements is very high, if the computation is very large (such as many codec operations), multi-application CPU core number, for the production of many objects, multi-application memory, and for many IO operation, bandwidth must keep up, such as you only apply 2MB, if your system and external interaction frequent, personal experience, 2MB is far from enough.
In addition, the number of connections to the MySQL service you have to look at the connection pool things.
About Tomcat optimization records and ideas