In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "the operation and tuning methods of Tomcat". In the daily operation, I believe that many people have doubts about the operation and tuning methods of Tomcat. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "operation and tuning methods of Tomcat". Next, please follow the editor to study!
The default configuration of Tomcat, performance is not optimal, we can optimize tomcat to improve the concurrency ability of the website. Improving the performance of Tomcat can be divided into two directions.
Server resources
The performance of CPU, memory and hard disk provided by the server has a decisive impact on the processing power, so the performance of the server is not too bad. Of course, to improve the hardware configuration of the server, you need a lot of RMB support. Therefore, this approach will not be adopted as a last resort, and companies will generally adopt the following way to improve the performance of Tomcat by optimizing configuration.
Optimize the configuration
Before optimizing the configuration, we need to configure a tomcat administrator account to log in to view the various parameters improved by the Tomcat console.
Add users under conf/ tomcat-users.xml:
Start tomcat, log in to view information: http://127.0.0.1:8080/
Three operating modes of tomcat
There are three modes of operation of tomcat:
Bio:
The default mode, performance is very low, without any optimization and support.
Nio:
Nio (new new O) is a new mode of operation (i.e. java.nio package and its subpackages) provided by Java SE 1.4 and subsequent versions. Java nio is a buffer-based Java API that provides non-blocking Imax O operations, so nio is also regarded as an acronym for non-blocking Imax O. It has better concurrency performance than the traditional Iram O operation (bio).
Apr:
Installation is the most difficult, but from the operating system level to solve the asynchronous IO problem, greatly improve performance.
Start NIO mode
Modify the Connector node in server.xml and change protocol to org.apache.coyote.http11.Http11NioProtocol
Actuator optimization (thread pool)
Every user request in tomcat is a thread, so thread pooling can be used to improve performance.
Open and use
Configuration:
Specify the use of a shared thread pool in Connector
View the Tomcat console
Description of important parameters of Executor:
Name: the name of the shared thread pool. This is the name that Connector will reference in order to share the thread pool, and the name must be unique. Default value: None
NamePrefix: on JVM, each running thread can have a name string. This property sets a prefix to the name string for each thread in the thread pool and Tomcat appends the thread number to this prefix. Default value: tomcat-exec-
MaxThreads: the maximum number of threads this thread pool can hold. Default value: 200
MaxIdleTime: the amount of time (in milliseconds) that idle threads are allowed to last before Tomcat shuts down an idle thread. Idle threads will be closed only if the number of currently active threads is greater than the value of minSpareThread. The default value is 60000 (one minute).
The minimum number of inactive threads that minSpareThreads:Tomcat should always open. Default value: 25.
ThreadPriority: the level of the thread. Default is Thread.NORM_PRIORITY
Description of important parameters of Connector:
Executor: indicates the thread pool corresponding to the value of this parameter
MinProcessors: the number of threads created to process requests when the server starts
MaxProcessors: the maximum number of threads that can be created to process requests
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.
Parameter best practices
Disable AJP Connector
AJP (Apache JServer Protocol)
The AJPv13 protocol is packet oriented. The WEB server and the Servlet container interact through TCP connections; to save the expensive cost of SOCKET creation, the WEB server attempts to maintain a permanent TCP connection to the servlet container and reuses the connection during multiple request and response cycles.
We generally use the Nginx+tomcat architecture, so we don't need the AJP protocol, so disable the AJP connector.
You can no longer see ajp in the administrative interface:
At this point, the study of "the method of running and tuning Tomcat" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.