Some common optimization techniques for Tomcat

Source: Internet
Author: User

This introduction is how to simply optimize the Tomcat server, if the user concurrency is small, the system may not be a problem, but the concurrency is large, the system response speed drops, because do not understand the reason desperately in their own applications to find problems, thus wasting valuable time. Let's look at how Tomcat is optimized.

(1) Masking DNS queries

Web applications can gain access to the IP address and name of the Web App customer through the Getremotehost () method provided by the Web container, but this consumes the resources of the Web container and also needs to reverse the user's name through the IP address and DNS server. Therefore, when the system is on-line, this property can be closed, thereby reducing resource consumption, then the Web application can only record the IP address. The modified property is Enableloopups= "false".

(2) Adjust the number of threads

Tomcat provides a response to user access through the line pool, and then adjusts the thread pool capacity after a preliminary estimate of the number of concurrent users in the on-line system. For example, when the number of concurrent users is around 100, you can set minprocessors= "", maxprocessors= "100". After setting the maximum and minimum to the same, the thread pool no longer frees idle threads, and when user access suddenly increases, no more system resources need to be consumed 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, there is no need to set this value too high, the system needs to consume a lot of resources to switch threads, but if the settings are too low will cause the application can not meet the user concurrency needs. So set this best can combine the whole system tracking and tuning, so that the system to achieve the best stable state, generally set to maxprocessors 1.5 times times.

(4) Adjust network timeout

The main is the HTTP protocol also has a connection process, the client is connected to the server, if the long time has not been processed will be released. If the server processing speed is slow, but it is hoped that each user can be effectively handled, or the network environment is not good, you need to ensure that users do not because of time-out interruption, can also be extended. However, it is generally set to connectiontimeout= "30000". Too long for the system is not worth much, but it will waste system resources on a meaningless long connection.

(5) The specific changes are as follows.

Minprocessors: The minimum number of idle connection threads used to improve system processing performance, with a default value of 10.

Maxprocessors: Maximum number of connection threads, which is the maximum number of requests that are processed concurrently, the default value is 75.

Acceptcount: The maximum number of connections allowed, should be greater than or equal to Maxprocessors, the default value is 100.

Enablelookups: Whether to reverse the domain name, the value is true or false. To improve processing power, set to false.

ConnectionTimeout: Network connection timed out in milliseconds. A setting of 0 means that it never times out, but this setting has a hidden risk and can typically be set to 20000 milliseconds.


This article is from the "Daily Operations" blog, please be sure to keep this source http://suochixiang.blog.51cto.com/10219965/1749576

Some common optimization techniques for Tomcat

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.