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