Martin Liu

Martin Liu

Senior Developer Relations/Advocate, Founder of DevOps China, Microsoft MVP

Martin Liu

2 分钟

Tomcat Configuration 查看一下可以配置的参数TomCat

设置 JVM 的参数 Setting JVM Options for Tomcat

Edit the /usr/locat/apache-tomcat/bin/ file and add the JVM options to the JAVA_OPTS environment variable.JVM Option Value Description
-Xmx 4g The maximum Java heap size.
-Xms 4g The initial Java heap size.
-Xmn 1g The size of young generation.
-XX:+UseParallelGC – To use parallel garbage collection for scavenges.
-XX:PermSize 50m The initial size of permanent generation.
注释:上面两个 4g 的值,我没试过,我用 8GB 内存 windows 的机器 1.5GB 能启动,超过了 Tomcat 服务就启动不了了。

配置 Tomcat Connector Attributes
Edit the /usr/locat/apache-tomcat/conf/server.xml file and add the attributes listed in Table 3 to the Connector element.


Tomcat Configuration Attribute Value Description
The maximum number of request processing threads to be created by this connector, which therefore determines the maximum number of simultaneous requests that can be handled. If not specified, the default value for this attribute is 40. If an executor is associated with this connector, this attribute is ignored and the connector executes tasks using the executor rather than an internal thread pool.
maxThreads 3000
The maximum queue length for incoming connection requests when all
possible request processing threads are in use. Any requests received when
the queue is full are refused. The default value is 10.
acceptCount 2000
The number of request processing threads that are created when this connector
is first started. The connector also verifies that it has the specified number of
idle processing threads available. This attribute should be set to a value smaller
than that set for maxThreads. The default value is 4.
minSpareThreads 500
The maximum number of unused request processing threads that are allowed
to exist until the thread pool starts stopping the unnecessary threads. The
default value is 50.
maxSpareThreads 2000
Set to “true” if you want calls to request.getRemoteHost() to perform DNS
lookups in order to return the actual host name of the remote client. Set to
enableLookups false “false” to skip the DNS lookup and return the IP address in String form instead
(thereby improving performance). By default, DNS lookups are enabled.

上面的值比我实际使用的大,我的 200 并发测试通过了,硬件配置见前一帖。




This Blog is sharing DevOps and SRE ariticles. I am a Senior Developer Relations/Advocate at Elastic, Founder of DevOps China since 2017, Microsift MVP since 2021, DevOps Institute Ambassador.