Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Simple arrangement of tomcat performance optimization

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Tomcat itself optimization

Tomcat memory optimization startup tells JVM that I want a large piece of memory (tuning memory is the most direct way) We can set the java_OPTS parameter JAVA_OPTS parameter in the startup script catalina.sh of tomcat to specify the server enabled server version of Xms java virtual machine initialization maximum memory XX: PermSize memory persistent reserved area XX:MaxPermSize memory maximum permanent reserved area configuration Example: JAVA_OPTS='-Xms1024m-Xmx2048m-XX: PermSize=256M-XX:MaxNewSize=256m-XX:MaxPermSize=256m' description: the memory configuration needs to be based on the actual memory of the server (or virtual machine) to configure restart tomcat effective Tomcat IO optimization how to use APR to solve asynchronous IO problems from the operating system level. The second is NIO. Tomcat threads optimize maxThreads= "600s" / / maximum number of threads in server.xml minSpareThreads= "100s" / number of threads created during initialization maxSpareThreads= "500" / once the number of threads created exceeds this value, Tomcat shuts down the socket threads that are no longer needed. AcceptCount= "700000" / / specifies the number of requests that can be placed in the processing queue when all available threads are used, and requests beyond this number will not be processed using thread pools to add executor nodes to server.xml, and then configure the executor property of connector NamePrefix: named prefix maxThreads for threads in thread pool: maximum number of threads in thread pool minSpareThreads: minimum number of idle threads in thread pool maxIdleTime: when the minimum number of idle threads is exceeded, more threads will wait for this length of time, and then turn off threadPriority: thread priority disable DNS query

When the web application records the information of the client, it also records the IP address of the client or converts the machine name to the IP address through the domain name server. DNS queries take up the network and include the process of getting the corresponding IP from many remote or ineffective servers, which can take a certain amount of time. To eliminate the performance impact of DNS queries, we can close DNS queries by modifying the cache optimization of enableLookups parameter values in the server.xml file

It is best to cache static pages so that you do not have to read from disk every time. Here we use Nginx as the cache server to cache images, css and js files, which effectively reduces the access to the back-end tomcat. Tomcat enables GZIP compression to improve web performance

Modify% TOMCAT_HOME%/conf/server.xml, and the revision node is as follows: shortcomings of GZIP. Compared with the projects without GZIP, the use of GZIP increases the pressure of server compression (cpu consumption) and client decompression, so the configuration of the server is more demanding. In addition, compression also takes time. If you want to take up less space and get a high compression ratio, you must sacrifice a long time. On the other hand, if time is more precious and requires speed, then the resulting compression ratio must be smaller, which will of course take up more space (compression ratio = original content size / post-compression size, the greater the compression ratio. It shows that the smaller the compression package that takes up space after compression), which is the contradiction between physical space and time. To optimize the operating system of cluster jvm virtual machine with nginx, it is to increase the available memory capacity, increase the frequency of CPU, and ensure the read and write rate of the file system as far as possible.

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report