BlueXIII's Blog

热爱技术,持续学习

0%

Tomcat优化配置

server.xml测试

Connector->maxThreads,在64核下设置成200最优,设300或更高反而增加CPU切换时间大幅降低TPS。查资料默认值就是200,此参数不用设置。
Connector->minSpareThreads,设成200或直接用默认值25,没有区别
Connector->maxConnections,

server.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?xml version="1.0" encoding="UTF-8"?>
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>

<Service name="Catalina">

<!-- <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="1024" minSpareThreads="128"/> -->

<!-- <Connector executor="tomcatThreadPool"
protocol="org.apache.coyote.http11.Http11Nio2Protocol"
port="8080"
maxConnections="40000"
acceptCount="40000"
enableLookups="false"
disableUploadTimeout="true"
useSendfile="true"
connectionTimeout="60000"
redirectPort="8443"
URIEncoding="UTF-8"
compression="on"
compressionMinSize="1024"
compressibleMimeType="text/html,text/xml,text/plain,text/css,text/javascript,application/javascript"
/> -->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
maxConnections="20000"
redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>

<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t &quot;%r&quot; %s %b" />

</Host>
</Engine>
</Service>
</Server>