Tomcat 7.x/8.x Optimization

Source: Internet
Author: User
Tags apache tomcat

First, optimize the connector
Http://www.aikaiyuan.com/8466.html

Tomcat has 3 modes of operation

1) bio

The default mode, performance is very low, without any optimization processing and support.

2) NiO

Using Java's asynchronous IO Care technology, noblocking IO technology.

Want to run in this mode, directly modify the connector node in the Server.xml, modify the protocol to

Protocol= "Org.apache.coyote.http11.Http11NioProtocol"
Once started, it can take effect.
(http://www.365mini.com/page/tomcat-connector-mode.htm)
3) Apr

Installation is the most difficult, but from the operating system level to solve the asynchronous IO problem, greatly improve performance.

Second, Apache Tomcat 8 WebSocket how-to Chinese Translation version
http://blog.csdn.net/hills/article/details/39368951

The Java WebSocket 1.0 specification requires that an asynchronous write callback be performed on a different thread to the thread that originated the write.
Since the container thread pool is not exposed through the Servlet API, the WebSocket implementation must provide its own thread pool. The thread pool can be controlled by the following servlet context initialization parameters:

The core size of the org.apache.tomcat.websocket.executorCoreSize:executor thread pool. If not set, the default is 0.
The maximum allowable value of the org.apache.tomcat.websocket.executorMaxSize:executor thread pool. If not set, the default is 200.
The maximum time that the idle process in the org.apache.tomcat.websocket.executorKeepAliveTimeSeconds:executor thread pool retains. If not specified, the default is 60 seconds.

Setup method:
In Web. xml

<!--WebSocket Core capacity size of executor thread pool -<Context-param><Param-name>Org.apache.tomcat.websocket.executorCoreSize</Param-name><Param-value>200</Param-value></Context-param><!--WebSocket Maximum capacity size of executor thread pool -<Context-param><Param-name>Org.apache.tomcat.websocket.executorMaxSize</Param-name><Param-value>1000</Param-value></Context-param>

Three, set the maximum number of threads
Apache-tomcat-7.0.73\conf\server.xml

<port= "8080"  protocol= "http/1.1"connectiontimeout = "20000" Redirectport = "8443" />


Or

<Executorname= "Tomcatthreadpool"Nameprefix= "catalina-exec-"MaxThreads= "+"minsparethreads= "4"/><ConnectorExecutor= "Tomcatthreadpool"Port= "8080"Protocol= "http/1.1"ConnectionTimeout= "20000"Redirectport= "8443" />


Reference:
Http://stackoverflow.com/questions/24889113/websocket-allows-only-200-connections
http://hongjiang.info/tomcat-connector-tuning-2/

Iv. self-characterencodingfilter set code to solve garbled problem
See Apache-tomcat-7.0.73\conf\web.xml

<!--A filter that sets character encoding that's used to decode -<!--parameters in a POST request -<Filter><Filter-name>Setcharacterencodingfilter</Filter-name><Filter-class>Org.apache.catalina.filters.SetCharacterEncodingFilter</Filter-class><Init-param><Param-name>Encoding</Param-name><Param-value>UTF-8</Param-value></Init-param><async-supported>True</async-supported></Filter>

Finally: Spit a Groove:)

Tomcat 7.x/8.x Optimization

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.