优化tomcat性能

#catalina.bat
set JAVA_OPTS=-server -Xms2048M -Xmx2048M  -Xss512k -XX:+AggressiveOpts -XX:+UseBiasedLocking -XX:PermSize=256M -XX:MaxPermSize=512M -XX:+DisableExplicitGC -XX:MaxTenuringThreshold=25 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 -Djava.awt.headless=true


<!-- server.xml -->
 <Connector port="8080"
                 	 protocol="HTTP/1.1"
                Executorname="tomcatThreadPool"
               connectionTimeout="20000"
               URIEncoding="UTF-8"
               acceptCount="1000"
               acceptorThreadCount="2"
               maxConnections="1000"
               maxThreads="1000"
               minSpareThreads="100"
               processorCache="5000"
               SSLEnabled="false"
               enableLookups="false" 
                compression="on" 
compressionMinSize="2048" 
compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain" 
               redirectPort="8443" />



<!-- web.xml -->

<filter>
        <filter-name>SimplePageCachingFilter</filter-name>
        <filter-class>net.sf.ehcache.constructs.web.filter.SimplePageCachingFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>SimplePageCachingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>



#web-inf/lib/
ehcache-core-2.4.6.jar
ehcache-web-2.0.4.jar
jstl.jar
jul-to-slf4j-1.6.1.jar
log4j-over-slf4j-1.6.1.jar
logback-classic-1.1.2.jar
logback-core-1.1.2.jar
slf4j-api-1.6.1.jar
standard.jar


<!-- ehcache.xml -->
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="./ehcache.xsd" updateCheck="true" monitoring="autodetect" dynamicConfig="true">

    <cache name="SimplePageCachingFilter"
           maxElementsInMemory="10000"
           eternal="false"
           overflowToDisk="false"
           timeToIdleSeconds="300"
           timeToLiveSeconds="60"
           memoryStoreEvictionPolicy="LFU" />

</ehcache>



<!-- ehcache.xml -->
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="./ehcache.xsd" updateCheck="true" monitoring="autodetect" dynamicConfig="true">

    <cache name="SimplePageCachingFilter"
           maxElementsInMemory="10000"
           eternal="false"
           overflowToDisk="false"
           timeToIdleSeconds="300"
           timeToLiveSeconds="60"
           memoryStoreEvictionPolicy="LFU" />

</ehcache>



<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
	<property name="BASE_LOG_PATH" value="log/test" />
	<appender name="DAY_FILE_ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<File>${BASE_LOG_PATH}/allerror.log</File>
		<encoder>
			<pattern>%d{MM-dd HH:mm:ss.SSS} | %p| %F:%L| %m%n%rEx</pattern>
		</encoder>
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<fileNamePattern>${BASE_LOG_PATH}/allerror.log.%d{yyyy-MM-dd}</fileNamePattern>
		</rollingPolicy>
	</appender>

	<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
		<encoder>
			<pattern>%d{MM-dd HH:mm:ss.SSS} | %p| %F:%L|  [%thread] [%X{traceId}] %m%n%rEx</pattern>
		</encoder>
	</appender>



	<root level="WARN">
		<!--<appender-ref ref="DAY_FILE_ERROR" />-->
		<appender-ref ref="STDOUT" />
	</root>
	

	
</configuration>






默认配置压测


修改tomcat和添加ehcache页面缓存后的结果


机器配置

优化tomcat性能_第1张图片

你可能感兴趣的:(优化tomcat性能)