In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail what are the test questions you often meet with Tomcat. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
What is the default port of Tomcat and how to modify it?
1) find the conf folder under the Tomcat directory
2) go to the conf folder and find the server.xml file
3) Open the server.xml file
4) find the following information in the server.xml file
Change port= "8080" to the port you want
2. What are the Connector operation modes (optimization) of tomcat?
Bio: the traditional Java Ithumb O operation that synchronizes and blocks IO. MaxThreads= "150th" / / Tomcat uses threads to process each request received. This value indicates that
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.
MinSpareThreads= "25"-the number of threads created during Tomcat initialization. The default is 4. If there are currently no idle threads and do not exceed the maxThreads, the number of idle threads created at one time.
The number of threads created during Tomcat initialization is also set by this value. MaxSpareThreads= "75"-once the created thread exceeds this value, Tomcat shuts down the socket thread that is no longer needed. The default is 50. Once the number of threads created exceeds this value, Tomcat shuts down threads that are no longer needed. The number of threads can be roughly calculated as the number of simultaneous online user operations per second, the system average operating time.
AcceptCount= "100th"-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. If the current number of available threads is 0, the request is placed in the processing queue. This value limits the size of the request queue, and requests beyond this value will not be processed. ConnectionTimeout= "20000"-the network connection timed out. The default 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.
Nio:JDK1.4 starts to support synchronous blocking or synchronous non-blocking IO. Specifies that the NIO model is used to accept HTTP requests
The protocol= "org.apache.coyote.http11.Http11NioProtocol" specifies that the NIO model is used to accept HTTP requests. Default is BlockingIO, configured to protocol= "HTTP/1.1" acceptorThreadCount= "2" the number of receiving threads when using the NIO model
Aio (nio.2): JDK7 starts to support asynchronous non-blocking IO.
Apr:Tomcat will call the core dynamic link library of the Apache HTTP server in the form of JNI to handle file reading or network transfer operations, thus greatly improving the performance of Tomcat in dealing with static files.
3. How many ways can Tomcat be deployed?
1) put the Web project directly under webapps, and Tomcat will deploy it automatically
2) configure the node on the server.xml file and set the relevant attributes
3) configure through Catalina: go to the conf\ Catalina\ localhost file and create a xml file whose name is the name of the site.
The way you write XML to set it up.
4. How does the tomcat container create servlet class instances? What principle is used?
When the container starts, it reads the web.xml files in all web applications in the webapps directory, then parses the xml files, and reads the servlet registration information. Then, the servlet classes registered in each application are loaded and instantiated by reflection.
(sometimes instantiated on the first request) when servlet registers, if it is positive, it is instantiated at the beginning, and if it is not written or is negative, the instantiation is requested for the first time.
5. How to optimize tomcat?
1. Optimize the connection configuration. Here, take the parameter configuration of tomcat7 as an example, you need to modify the conf/server.xml file, modify the number of connections, and close the client dns query. Parameter explanation:
URIEncoding= "UTF-8": it is convenient for tomcat to parse the url of files with Chinese names, unlike there is a mod_encoding in apache, and you have to compile maxSpareThreads manually: if there are more threads in idle state than you set, abort these threads and reduce the total number of threads in this pool.
MinSpareThreads: minimum number of spare threads, the number of threads initialized when tomcat starts.
EnableLookups: this effect is the same as that of HostnameLookups in Apache, which is set to off.
ConnectionTimeout: connectionTimeout is the number of milliseconds of network connection timeout.
MaxThreads: maxThreads Tomcat uses threads to process each request received. This value represents the maximum number of threads that Tomcat can create, that is, the maximum number of concurrency.
AcceptCount: acceptCount means that when the number of threads reaches maxThreads, subsequent requests will be put into a waiting queue. The acceptCount is the size of the queue. If the queue is full, refuse connection maxProcessors and minProcessors directly:
In Java, a thread is the path of a program when it runs, and it is a code segment that is independent of other control threads and can run independently in a program. They share the same address space. Multithreading helps programmers write efficient programs that maximize the utilization of CPU, keep idle time to a minimum, and accept more requests.
Usually the Windows is about 1000 and the Linux is about 2000.
This is the end of this article on "what are the test questions we often meet with Tomcat?". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.