Common Tomcat optimization skills and tomcat skills

Source: Internet
Author: User

Common Tomcat optimization skills and tomcat skills

(1) shield DNS queries

Web applications can use the getRemoteHost () method provided by Web containers to obtain the IP addresses and names of Web application customers. However, this consumes resources of Web containers, in addition, you also need to check the user's name through the IP address and DNS server. Therefore, when the system goes online, you can disable this attribute to reduce resource consumption, so that the Web application can only record the IP address. The modified attribute is enableLoopups = "false ".

(2) Adjust the number of threads

Tomcat provides responses for user access through the thread pool. After the online system preliminarily estimates the number of concurrent users, it then adjusts the thread pool capacity. For example, if the number of concurrent users is about 100, you can set minProcessors = "100" maxProcessors = "100" and set the maximum and minimum values to the same value, the thread pool will no longer release Idle threads, so that when user access suddenly increases, there is no need to consume system resources to create new threads.

(3) Adjust the maximum number of connections

This is actually the most complex. Even if the user concurrency is large, but the system response speed is fast, you don't need to set this value too high. In this case, the system needs to consume a lot of resources to switch threads, however, if the setting is too low, the application cannot meet the user's concurrent needs. Therefore, it is best to combine the tracking and tuning of the entire system to ensure the best stability of the system. It is generally set to 1.5 times the value of maxProcessors.

(4) Adjust network timeout

It is mainly because the HTTP protocol also has a connection process. After the client connects to the server, the client will be released after it is not processed. If the server processing speed is slow, but every user is expected to be effectively processed, or the network environment is poor, you must ensure that the user will not be disconnected due to timeout, or you can extend the time. But you can set it to connectionTimeout = "30000. Too long is of little value to the system, but will waste system resources on unnecessary persistent connections.

(5) The specific modification is as follows:

MinProcessors: Minimum number of idle connection threads to improve system processing performance. The default value is 10.

MaxProcessors: Maximum number of connection threads, that is, the maximum number of concurrent requests. The default value is 75.

AcceptCount: Maximum number of connections allowed. The value must be greater than or equal to maxProcessors. The default value is 100.

EnableLookups: whether to check the domain name. The value is true or false. To improve the processing capability, set it to false.

ConnectionTimeout: the network connection times out. Unit: milliseconds. If it is set to 0, it indicates that the timeout never expires. However, this setting is a hidden danger. It can usually be set to 20000 milliseconds.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.