Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the common optimized configurations of Tomcat?

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly shows you "what is the commonly used optimized configuration of Tomcat", the content is simple and clear, and I hope it can help you solve your doubts. Here, let the editor lead you to study and learn about "what is the common optimized configuration of Tomcat?"

1. Thin Tomcat and configuration Fil

1.1.Delete unwanted management applications and help applications to improve tomcat security.

# Delete all files under webapps

# rm-fr $CATALINA_HOME/webapps/*

# Delete all files under server/wenapps

# rm-fr $CATALINA_HOME/server/webapps/*

1.2.Compact sever.xml profile

Use the minimum configuration file in the tomcat release to improve performance and add feature configurations one by one if there is a functional need.

# back up the original server.xml as server.xml_bak

# mv server.xml server.xml_bak

# copy server-minimal.xml to server.xml

# cp server-minimal.xml server.xml

two。 Connector optimization

The Connetctor node in the $CATALINA_HOME/conf/server.xml configuration file, parameter configuration and optimization related to the number of connections.

MaxThreads

Tomcat uses threads to process each request received. This value represents the maximum number of threads that Tomcat can create. The default is 200. Can be adjusted according to the machine's performance and memory size, generally between 400 and 500. The maximum can be around 800.

AcceptCount

Specifies the number of requests that can be placed in the processing queue when all available threads for processing requests are used, and requests beyond this number will not be processed. The default is 10.

MinSpareThreads

The number of threads created during Tomcat initialization. The default is 4.

MaxSpareThreads

Once the created thread exceeds this value, Tomcat shuts down the socket thread that is no longer needed. The default is 50.

EnableLookups

Whether to reverse the domain name. The default value is true. In order to improve processing power, it should be set to false

ConnnectionTimeout

The network connection timed out. The default value is 20000, in milliseconds. Setting to 0 means that you will never time out, which is a hidden danger. It can usually be set to 30000 milliseconds. (due to the long timeout of the interface with the background system, the use of this system is set to 60000)

MaxKeepAliveRequests

Keep the number of requests. The default is 100.

BufferSize

Input stream buffer size, default is 2048 bytes.

Compression

Compressed transmission. Value on/off/force. Default is off.

The parameters related to the maximum number of connections are maxThreads and acceptCount. If you want to increase the number of concurrent connections, you should increase both parameters at the same time. The maximum number of connections allowed by web server is also subject to the kernel parameter settings of the operating system, usually around 2000 for Windows and about 1000 for Linux.

How to disable and allow files under column directories in Tomcat

In $CATALINA_HOME/conf/web.xml, set the listings parameter to false, as follows:

Listings

False

...

Concrete operation

# vi $CATALINA_HOME/conf/server.xml

Modify the connection for AJP:

Are:

Modify the generic connection:

Are:

Modify the host and application configuration:

Are:

3. Optimize JDK

The memory that can be used by Tomcat by default is 128MB of memory in Windows. Under the file {tomcat_home} / bin/catalina.bat,Unix, add the following settings before the file $CATALINA_HOME/bin/catalina.sh:

JAVA_OPTS='$JAVA_OPTS-Xms [initialization memory size]-Xmx [maximum memory that can be used]

Or

Set the environment variable: export JAVA_OPTS= "$JAVA_OPTS-Xms [initialization memory size]-Xmx [maximum memory that can be used]"

In general, you should use 80% of the physical memory as the heap size. If you have an Apache server on your machine, you can first convert the memory required by Apache, and then modify the heap size. It is recommended to set it to 70%. It is recommended that [[initialize memory size] is equal to [maximum memory that can be used], which can reduce the ordinary allocation heap and reduce performance.

This example uses the addition of environment variables:

# vi / etc/profile

Add: export JAVA_OPTS= "$JAVA_OPTS-Xms700-Xmx700

# source / etc/profile

The above is all the contents of the article "what is the common optimized configuration of Tomcat?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report