当前位置:网站首页>The interface request takes too long. Jstack observes the lock holding
The interface request takes too long. Jstack observes the lock holding
2022-04-23 02:42:00 【An effort to XX program yuan】
scene : In the engineering A Middle note project B The interface completes some logic ,A Print a message for each interface called in the , It is observed that when the interface is called continuously for a period of time , It'll stick for a while , Then continue to execute . The boss gives advice to check jstack dump Stack information , View blocking and time-consuming operations .
- At the command line terminal , Input jps View the current java process id;

- jstack –l PID >>log.txt, PID Refers to the process Id, Output the stack information to... In the current directory log.txt In file .

Explain the parameters :
-l long listings, Will print out additional lock information , It can be used in the lock of life and death jstack -l pid To observe lock holding
-m mixed mode, Not only will it output Java Stack information , It will also output C/C++ Stack information ( such as Native Method ) - A detailed analysis of the stack , Reference resources jstack dump Detailed analysis of log files
Through the above analysis , A synchronizer was found in the log printing in the project , As a result, all interfaces are waiting for log printing ; Another problem is that authentication is too slow .
solve :
- Log level is set to error, Reduce the resources occupied by log printing ,p6spy Turn off to reduce resource consumption , Printing logs is very resource consuming , The synchronization in the log makes the interface in a waiting state .
- tokenID Authentication uses local authentication , Or remove the certification , The original authentication using an Internet address , adopt Apache Access authentication interface ,Apache Default long connection , Will limit the number of connections , Waiting for connection release , Block the program .
besides , Setting that can increase the processing speed of the interface :
- Set up MySQL database ,my.ini
max_allowed_packet = 64M
innodb_buffer_pool_size =20G -- You don't have to set it too large ,4096M It's OK
- Set the number of connections to the database , Increase the number of initial connections , maximum connection :
# Define the initial number of connections
initialSize=10
# The maximum number of database connections for which the connection pool is active ,0 Means unrestricted , Indicates maximum concurrency
maxActive=200
# The maximum number of database connections for which the connection pool is idle , Take a non positive integer to indicate unrestricted , When this value is exceeded, redundant idle connections will be released
maxIdle=20
# The minimum number of database connections for which the connection pool is idle , Below this value will create the missing connection , set up 0 unlimited
minIdle=10
# When the connection pool runs out of connections , Waiting time for new requests ( That is, wait for other connections to be idle ), Timeout return exception , millisecond
maxWait=60000
- modify Tomcat,server.xml
<Connector
executor="tomcatThreadPool"
port="8280"
protocol="org.apache.coyote.http11.Http11Nio2Protocol"
enableLookups="false"
acceptCount="1500"
disableUploadTimeout="false"
connectionTimeout="180000"
connectionUploadTimeout="300000"
maxConnections="10000"
URIEncoding="UTF-8"
redirectPort="8443"
compression="on"
compressionMinSize="1024"
useSendfile="false"
keepAliveTimeout="60000"
tcpNoDelay="true"
noCompressionUserAgents="gozilla, traviata"
maxPostSize="-1"
maxParameterCount="-1"
compressibleMimeType="text/html,text/xml,text/plain,text/css,text/javascript,application/javascript " />
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="4"/>
take tomcat Change the maximum number of connections in the thread pool to maxThreads=200;
http Long connection timeout keepAliveTimeout Set to keepAliveTimeout="2000"ms, Just call me , You don't need to keep a long connection to get data , Just release the useless connection quickly .
版权声明
本文为[An effort to XX program yuan]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230239165395.html
边栏推荐
- Modification du contenu de la recherche dans la boîte déroulante par PHP + MySQL
- How big the program development of single chip microcomputer project can be, it represents your level of knocking code
- Probabilistic model of machine learning
- JVM runtime data area (I)
- 智能辅助功能丰富,思皓X6安全配置曝光:将于4月23日预售
- Understanding process (multithreading primary)
- 1215_ Hello world used by scons
- The usage and difference of * and & in C language and the meaning of keywords static and volatile
- A domestic image segmentation project is heavy and open source!
- 学习正则表达式选项、断言
猜你喜欢

【2019-CVPR-3D人体姿态估计】Fast and Robust Multi-Person 3D Pose Estimation from Multiple Views

Using go language to build web server

Target narak

16、 Anomaly detection

LeetCode 1450 - 1453

Intelligent agricultural management model

RT_Thread自问自答

Download the genuine origin Pro 2022 tutorial and how to activate it
![[xjtu Computer Network Security and Management] session 2 Cryptographic Technology](/img/b0/263e8dcbfeb2ce9f504a9c8eb76b07.png)
[xjtu Computer Network Security and Management] session 2 Cryptographic Technology

Web learning record (medium)
随机推荐
Synchronized锁及其膨胀
JVM class loader
电源电路设计原来是这么回事
MySQL complex query uses temporary table / with as (similar to table variable)
RT_ Thread ask and answer
能做多大的单片机项目程序开发,就代表了你的敲代码的水平
Go语言web中间件的使用
Jz76 delete duplicate nodes in linked list
Day 3 of learning rhcsa
【unity3D】直播间滚动式弹幕效果
Preliminary understanding of stack and queue
学习正则表达式选项、断言
[suggestion collection] hematemesis sorting out golang interview dry goods 21 questions - hanging interviewer-1
Classification and regression tree of machine learning
Cuisine leetcode
Web learning record (medium)
下载正版Origin Pro 2022 教程 及 如何 激 活
Learn regular expression options, assertions
期中汇总(概论+应用层+运输层)
How to build an integrated industrial Internet plus hazardous safety production management platform?