Visual VM

This is a visual tool integrated as part of the JDK, which has the capability to profile applications. Let's run our banking app from the previous chapters, and review which information we can gather using it.

To run our previous banking application, go to the project folder and run the following via the command line: java -jar build/libs/banking-app-1.0.jar.

Now, we are going to use the VisualVM to gather some metrics about the JVM. We can run this tool from the console using the following command:

$ cd JAVA_HOME/bin
$ jvisualvm

We should see a screen similar to the following screenshot: 

Java VisualVM

Using the Locals menu option, you have to attach the Java process that is going to be monitored. In this case, we are going to select banking-app-1.0.jar. Then, we should see a resume of the resources used for the application:

VisualVM CPU, RAM, classes, and threads 

There is also a tab that provides information about Threads, which is shown in the following screenshot:

VisualVM threads 

We can use any tool that we feel comfortable with; a great place to start, and a tool that is easy to use is Jprofiler, but all the tools give us similar information. We need to understand and follow the possible problems generated by any bottleneck that we find in our application.

Debugging performance issues in production can be a difficult task, and, in some cases hard to find and fix. We need a tool that we can feel confident about to understand the bottlenecks, so we need to try different tools and experiment load tests to find the right one for us.

Don't optimize before you know it's necessary; first, run the application and run a load test to see whether we can approach the non-functional requirements defined for performance.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.255.178