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 is the method of Tomcat advanced optimization in Web server

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly explains "what is the method of advanced optimization of Tomcat in Web server". The content of the explanation in this article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the method of advanced optimization of Tomcat in Web server".

JVM memory View of Tomcat

Here I use tomcat6 and tomcat7 to explain, tomcat7+ configuration, operation methods are similar.

User configuration for Tomcat6:

Tomcat6 configuration

User configuration for Tomcat7:

Tomcat7 configuration

After the above settings are completed:

Local access / localhost:8080/manager/status

Unoptimized pre-information

Startup Optimization of Tomcat

Modify the catalina.sh file in Linux and the catalina.bat file in windows. The contents are as follows:

Export JAVA_OPTS= "

-server

-Xms1600M

-Xmx1600M

-Xss512k

-XX:+AggressiveOpts

-XX:+UseBiasedLocking

-XX:PermSize=128M

-XX:MaxPermSize=256M

-XX:+DisableExplicitGC

-XX:MaxTenuringThreshold=31

-XX:+UseConcMarkSweepGC

-XX:+UseParNewGC

-XX:+CMSParallelRemarkEnabled

-XX:+UseCMSCompactAtFullCollection

-XX:LargePageSizeInBytes=128m

-XX:+UseFastAccessorMethods

-XX:+UseCMSInitiatingOccupancyOnly

-Djava.awt.headless=true "

Check whether it is effective or not

Concurrent Optimization of Tomcat

Modify the location:

To optimize the configuration of nodes in the server.xml file under / opt/tomcat7/conf, be sure to back up first.

Standard Edition Optimization:

Complex version optimization:

Tomcat memory optimization

Error troubleshooting:

Check the log file under the% TOMCAT_HOME%\ logs folder for memory overflow errors

Error tip 1: java.lang.OutOfMemoryError: Java heap space

Cause:

The default memory available for Tomcat is 128MB, which is not enough in larger application projects and may cause the system to fail to run.

The common problem is to report a Tomcat memory overflow error and an exception of Out of Memory (system out of memory), which causes the client to display 500error.

Generally, adjusting the memory used by Tomcat can solve this problem.

Solution:

Modify in Windows environment:

"% TOMCAT_HOME%\ bin\ catalina.bat" file, add the following settings at the beginning of the file:

JAVA_OPTS=-Xms2048m-Xmx2048m

Modify in Linux environment:

"% TOMCAT_HOME%\ bin\ catalina.sh" file, add the following settings at the beginning of the file:

JAVA_OPTS=-Xms2048m-Xmx2048m

Error tip 2: java.lang.OutOfMemoryError: PermGen space

Cause

The full name of PermGen space is Permanent Generation space, which refers to the permanent storage area of memory. This memory is mainly stored in Class and Meta information by JVM. Class will be placed in PermGen space when it is Loader. Unlike the Heap area where class instances (Instance) are stored, GC (Garbage Collection) will not clean up PermGen space during the run time of the main program, so if you have a lot of CLASS in your application, PermGen space errors are likely to occur. This kind of error is common when the web server pre-compile JSP. If you use a large number of third-party jar under your WEB APP, its size exceeds the default size of jvm (4m), then this error message will be generated.

Solution:

Modify in Windows environment:

"% TOMCAT_HOME%\ bin\ catalina.bat" file, add the following settings at the beginning of the file:

Set JAVA_OPTS=-Xms64m-Xmx256m-XX:PermSize=128M-XX:MaxNewSize=256m-XX:MaxPermSize=256m

Modify in Linux environment:

"% TOMCAT_HOME%\ bin\ catalina.sh" file, add the following settings at the beginning of the file:

Export JAVA_OPTS=-Xms64m-Xmx256m-XX:PermSize=128M-XX:MaxNewSize=256m XX:MaxPermSize=256m

Modify the location in windows:

Ab stress Test of Apache

Download the httpd-2.2.29.tar.gz package

/ opt decompress: httpd-2.2.29.tar.gz

Root directory / under:

Mkdir-p / usr/local/web/apache

Enter the httpd-2.2.29 folder under / opt: cd httpd-2.2.29

Installation

. / configure-prefix=/usr/local/web/apache-enable-shared=max-enable-module=rewirte-enable-module=so

Make

Make install

The ab stress test begins:

Go to the / usr/local/web/apache/bin directory and execute the following command:

Ab-n1000-c100 / localhost:8080/

Report description

Thank you for reading, the above is the content of "what is the method of advanced optimization of Tomcat in Web server". After the study of this article, I believe you have a deeper understanding of what the method of advanced optimization of Tomcat in Web server is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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

Servers

Wechat

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

12
Report