Because the customer server special environment problem, can only use WINDOWS2008R2 server, but after the configuration, the site of high traffic quickly appeared a variety of problems, the following is a summary of the problem solved.
Server environment: WINDOWS2008R2+JDK8.0+TOMCAT8.0.21+SQLSERVER2008R2 (the above software environment is 64-bit)
1, first of all, it is recommended to install jdk8.0 (64-bit) to obtain a higher JVM memory settings, or the site access is too high, memory will soon appear insufficient, that is, often said Java heap space is insufficient. : http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Remember to choose: Jdk-8u45-windows-x64.exejdk-8u45-windows-x64.exejdk-8u45-windows-x64.exe
2, the installation of 64-bit tomcat8.0, the latest version is apache-tomcat-8.0.21,:http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.0.21/bin/ Apache-tomcat-8.0.21-windows-x64.zip
3, modify the connector protocol, the default is http/1.1, the default setting does not support excessive concurrency, or an IO error occurs. method is to modify Conf/server.xml <connector port= "8080" protocol= "http/1.1" to < Connector port = "8080" protocol = "Org.apache.coyote.http11.Http11NioProto Col "
4, optimize the jar package, if a jar file appears in multiple Web applications, the jar file can be unified into a directory, to avoid being loaded by Tomcat multiple times, memory consumption. The method is:
Modified:/conf/catalina.properties File
Will:
Common.loader= "${catalina.base}/lib", "${catalina.base}/lib/*.jar", "${catalina.home}/lib", "${catalina.home}/lib /*.jar "Rear add:" ${catalina.home}/share/lib/*.jar "
Then place the shared jar file in the Lib folder in the share directory under Tomcat.
5, TOMCAT8 cache the image resources by default, when the concurrency is too high, will prompt warn information: WARNING [http-nio-80-exec-43] Org.apache.catalina.webresources.Cache.getResource Unable to add the resource at ..., this itself has no problem, just keep writing information in the log, Log files are constantly increasing, feeling bad, simply set not caching, by:
Modify the Context.xml file under Meta-inf, add a line in the context: <resources cachingallowed= "false" ></Resources>
6. Set the JVM large memory, edit Bin/catalina.bat, find the following code snippet: REM Guess catalina_home if not defined, add code above it:
Set java_opts=-xms512m-xmx4096m-xx:permsize=128m-xx:maxpermsize=256m
The XMX set here is 4G of memory, if the installation is not 64-bit JDK, then set the maximum memory, you will be prompted not to support (as if the maximum can be set to 1G multipoint, to know that the server memory is 64G AH,!!!). So the first step is why the 64-bit operating system is installed.
7, set the maximum number of Tomcat concurrency, method: Modify Conf/server.xml, add the following code under connector: maxthreads= "" "Minsparethreads=" maxsparethreads= " "Acceptcount=" 100 "
Here is my configuration:
<connector port= "protocol=" Org.apache.coyote.http11.Http11NioProtocol " connectiontimeout=" 20000 " maxthreads= "minsparethreads=" "maxsparethreads=" " acceptcount=" redirectport= "8443" uriencoding= "GBK" usebodyencodingforuri= "true" />
Because most of the time the JSP program is deployed under Linux, did not think of Windows will have so many problems, the above is tested, the site in the high traffic no more problems. Also tested under Windows Server, the method of using Apache+tomcat integration is not good either. Support for concurrent connections is less than pure tomcat.
A solution to the problem of tomcat8 under high concurrency under windows2008