Tomcat is deployed on the Linux server. After a period of time, it cannot access the web interface and prompts that the connection is reset

CSDN Q & A 2022-02-13 08:41:05 阅读数:240

tomcat deployed linux server. server

tomcat The service is deployed on a single server , Probably 400 People are using , After a while, you won't be able to visit web Interface , The browser interface prompts that the connection is reset , however tomcat There is no error in the log and it is still running normally , netstat -anop|grep 11000 View connections 40 Multiple SYN_RECV State connection , I doubt it. tcp The problem of connection leads to the failure of connection , But you can't reproduce




Take the answer :

Hello , In your case , I understand it's your tomcat It's deployed in linux A node on . External network access is provided , Really? . If it's like this ,400 Personal visit , It may occur that the response cannot be received in time due to concurrency . The performance page may not open 、 White page waiting . If you call out f12 Words , You see if there is pending Resource loading of . No error is reported in the server-side log , Explain that it's not a business error report , It should be a performance problem . tcp A large number of are connected , A lot of io resources . I suggest you check in two ways : Check on the host side Connection number setting , Optimize linux The kernel is about tcp Connection parameters ; Check the application side to see if there is gc , etc. , in addition tomcat Adjust the number of threads . Generally, a single node seems to be 400 Concurrent threads . More requests , There will be a blocking wait .



Other answers 2:

1、 see tomcat Service application log path */logs/catalina.out Log output of
tail -100 calalina.out
See the following error :
2018/04/06-19:24:16 >> ERROR >> catalina-exec-3981 >> org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1515) >>
java.lang.OutOfMemoryError: PermGen space
2018/04/06-19:26:03 >> INFO >> catalina-exec-3982 >> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:203) >> 19:26:03.114 [catalina-exec-3982] INFO monitoring - remoteAddr = 130.81.10.3, request = / GET: 2918 ms, erreur, 0 Ko
2018/04/06-19:26:03 >> ERROR >> catalina-exec-3982 >> org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1515) >>
java.lang.OutOfMemoryError: PermGen space
It can be concluded that it is a memory overflow .
2、 see linux The system limits the number of applications
ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
pending signals (-i) 1024
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 212992
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
Process open files The maximum is 1024 File , Default
3、 Use root User view linux System How many file handles are open in the current process
lsof -n |awk '{print $2}'|sort|uniq -c |sort -nr|more
4192 67896
Open file 4192, process 67896
Check the process
ps -ef |grep 67896
webuser 67896 1 52 Apr03 ? 3-14:02:26 /usr/java/jdk1.7.0_79/bin/java -Dnop -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xms1024m -Xmx1024m -XX:PermSize=64m -XX:MaxPermSize=128m -javaagent:/appdynamics/AppServerAgent/javaagent.jar -Djava.endorsed.dirs=/tomcat-8.0.30/endorsed -classpath /tomcat-8.0.30/bin/bootstrap.jar:/tomcat-8.0.30/bin/tomcat-juli.jar -Dcatalina.base=/tomcat-8.0.30 -Dcatalina.home=/tomcat-8.0.30 -Djava.io.tmpdir=*/tomcat-8.0.30/temp org.apache.catalina.startup.Bootstrap start
Find the specified process java Number of open files 4192, Far more than 1024, overflow .
Transfer memory from 2C/12G Expand into 4C/12G
take tomcat/bin/calalina.sh To configure
Adjusted for JAVA_OPTS="-Xms2048m -Xmx4096m -XX:PermSize=512m -XX:MaxPermSize=1024m"
Then restart the observation


Other answers 3:

1. Route tracking (tracert), Discover that you can reach the server , Basically eliminated the problem of the line .

2. Check 80 port (tracetcp), Local port connectivity test , The test results are OK ( attach :tracetcp Usage method https://help.aliyun.com/knowledge_detail/40572.html).

3. Check the firewall , Before , I will the firewall CC The protection mode is changed to “ emergency ”, Is it “ emergency ” The model has caused a miscarriage of life to the website , So I changed the firewall protection mode to “ normal ”, Visit the website again , Found that most of the pages basically no longer appear “ Connection reset ” The phenomenon , But on certain pages ( Form submission ) The connection will still be reset , Query information , Found to be client_max_body_size The problem with this parameter , stay nginx In the configuration file (nginx.conf), Add this parameter :client_max_body_size  30M, revisit , Problem solving .

4. Online query information says that if a proxy server is used , There are similar problems , Introduce the following code into the configuration file to solve ( notes : Not personally verified ).

proxy_set_header      Host            $host;
proxy_set_header      X-Forwarded-For $proxy_add_x_forwarded_for;


Other answers 4:

1、 see tomcat Service application log path */logs/catalina.out Log output of
tail -100 calalina.out
See the following error :
2018/04/06-19:24:16 >> ERROR >> catalina-exec-3981 >> org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1515) >>
java.lang.OutOfMemoryError: PermGen space
2018/04/06-19:26:03 >> INFO >> catalina-exec-3982 >> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:203) >> 19:26:03.114 [catalina-exec-3982] INFO monitoring - remoteAddr = 130.81.10.3, request = / GET: 2918 ms, erreur, 0 Ko
2018/04/06-19:26:03 >> ERROR >> catalina-exec-3982 >> org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1515) >>
java.lang.OutOfMemoryError: PermGen space
It can be concluded that it is a memory overflow .
2、 see linux The system limits the number of applications
ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
pending signals (-i) 1024
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 212992
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
Process open files The maximum is 1024 File , Default
3、 Use root User view linux System How many file handles are open in the current process
lsof -n |awk '{print $2}'|sort|uniq -c |sort -nr|more
4192 67896
Open file 4192, process 67896
Check the process
ps -ef |grep 67896
webuser 67896 1 52 Apr03 ? 3-14:02:26 /usr/java/jdk1.7.0_79/bin/java -Dnop -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xms1024m -Xmx1024m -XX:PermSize=64m -XX:MaxPermSize=128m -javaagent:/appdynamics/AppServerAgent/javaagent.jar -Djava.endorsed.dirs=/tomcat-8.0.30/endorsed -classpath /tomcat-8.0.30/bin/bootstrap.jar:/tomcat-8.0.30/bin/tomcat-juli.jar -Dcatalina.base=/tomcat-8.0.30 -Dcatalina.home=/tomcat-8.0.30 -Djava.io.tmpdir=*/tomcat-8.0.30/temp org.apache.catalina.startup.Bootstrap start
Find the specified process java Number of open files 4192, Far more than 1024, overflow .
Transfer memory from 2C/12G Expand into 4C/12G
take tomcat/bin/calalina.sh To configure
Adjusted for JAVA_OPTS="-Xms2048m -Xmx4096m -XX:PermSize=512m -XX:MaxPermSize=1024m"
Then restart the observation
————————————————
Copyright notice : This paper is about CSDN Blogger 「 Cannon 2020」 The original article of , follow CC 4.0 BY-SA Copyright agreement , For reprint, please attach the original source link and this statement .
Link to the original text :https://blog.csdn.net/u012034742/article/details/79908967

copyright:author[CSDN Q & A],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/02/202202130841029833.html