About Tomcat optimization records and ideas

Source: Internet
Author: User
Tags xeon e5

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 <Connectorport="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/jfinalBeetlThis 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 requestsCompleted 200 requestsCompleted 300 requestsCompleted 400 requestsCompleted 500 requestsCompleted 600 requestsCompleted 700 requestsCompleted 800 requestsCompleted 900 requestsCompleted 1000 requestsFinished 1000 requestsServer Software:        Apache-Coyote/1.1Server Hostname:        192.168.xx.xxxServer Port:            7080Document Path:          /jfinalBeetlDocument Length:        327 bytesConcurrency Level:      50Time taken for tests:   0.656 secondsComplete requests:      1000Failed requests:        0Write errors:           0Non-2xx responses:      1000Total transferred:      146000 bytesHTML transferred:       0 bytesRequests 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] receivedConnection Times (ms)              min  mean[+/-sd] median   maxConnect:        0    0   2.6      0      16Processing:     0   32   6.3     31      47Waiting:        0   20  11.2     16      47Total:          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/RootThis 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 requestsCompleted 200 requestsCompleted 300 requestsCompleted 400 requestsCompleted 500 requestsCompleted 600 requestsCompleted 700 requestsCompleted 800 requestsCompleted 900 requestsCompleted 1000 requestsFinished 1000 requestsServer Software:        Apache-Coyote/1.1Server Hostname:        192.168.xx.xxxServer Port:            7080Document Path:          /RootDocument Length:        11430 bytes Concurrency Level:      50Time taken for tests:   1.297 secondsComplete requests:      1000Failed requests:        0Write errors:           0Total transferred:      11571000 bytesHTML transferred:       11430000 bytesRequests 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] receivedConnection Times (ms)              min  mean[+/-sd] median   maxConnect:        0    1   4.1      0      16Processing:    16   62   9.7     63      94Waiting:        0   29  18.1     31      78Total:         16   63   9.5     63      94Percentage 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给的几个参数,你先别忙着上集群,试试这些,tomcat81.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.shexport 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.