During application maintenance for the customer, I noticed some performance problems under high load conditions. Theoretically, increasing the load on the application will reduce the performance, but I think the performance drop rate is much higher than the load increase. At the same time, I also found that, performance can be improved by changing the logic of the application. To learn more about this, we need to perform some performance analysis. At this time, we naturally need to use some performance analysis tools. Java has many performance analysis tools to help us figure out this problem, but which tool should we use?
In order to make the right choice, I listed performance analysis should meet some minimum requirements:
- Must include monitoring of application classes, methods, and time
- Memory monitoring must be included
- Must be easy to use
I have configured a spring application that uses restful interfaces, uses MongoDB as the data storage, uses SOLR search, and deploys it on the Tomcat server.
Reference tools:
1. visualvm
Visualvm is a resource analysis tool that has been updated from JDK 6 to 7. It monitors memory and CPU by default. It can tell you which class and method consumes resources, but it does not display the code flow.
2. jprofiler
Jprofiler is easy to install, and you can select the application server to run the application through the wizard. I have to select the main directory of the jpofiler application server and a separate STARTUP script generated by the wizard. Then run the server. During the session listening process, it provides several options, which can record the memory usage and CPU usage. While viewing the CPU usage, you can see the execution path. This shows that most of the application's time is spent on requests. We can install the intellij plug-in on the IDE, so it is more convenient to run jprofiler. For example, you can help me start Tomcat directly.
3. yourkit
Yourkit is a performance analysis tool that I accidentally found in another project. It is easy to install. There is an option to install a plug-in to my ide. After installation, run the application. With this plug-in, it will automatically connect to yourkit. It has a beautiful user interface that allows you to view the memory and CPU monitoring, as well as the request execution path.
4. Jprobe
I encountered some difficulties when I first created Jprobe. The installation is not completed directly. I need to configure it. It uses settings similar to jprofiler. It will generate a STARTUP script in your Tomcat directory. You can use the script to start the server and listen to sessions. The Interface contains buttons and tables. The memory usage is displayed, but the execution path cannot be found in the process.
5. Spring insight
When I heard that the TC server has the spring insight monitoring interface, I tried it excitedly. After the installation is complete, set it to the developer version of the TC server, and then deploy the application on the TC server. I checked the insight interface, which can monitor classes and methods well and see how long it took to complete this method. I can also see the input parameter values and return values. Since my application is based on spring, spring insight can provide very useful data. The configuration of the TC server plug-in on IDE is similar to that of Tomcat. Springsource tool kit comes with spring
Insight.
Conclusion
I can certainly say that these five performance analysis tools are all very good. If you have spring-based applications, it is obvious that spring insight is the best choice. It is always free, but you need to deploy your application on the TC server.
If you want to listen to local and remote processes, I will select jprofiler or yourkit. These two can also help spring insight to monitor and find performance bottlenecks.
Jprofiler and yourkit can already meet my above requirements. Jprofiler, yourkit, and spring insight can trace the flow of classes and methods of applications. Jprofiler and yourkit can display memory usage. Although spring insight cannot display memory usage, it can display the throughput trend well. These three performance analysis tools are clearly functional and easy to use. Finally, they all have their own ide plug-ins. I hope this article will help you make the right choices.
From: chinaitlab