Profiling with JProfiler

JProfiler is one of the most commonly used tools for profiling in enterprise applications. It is simple to use and integrated with IDEs such as Eclipse, IntelliJ Idea, and many more. It can be used to profile locally deployed applications or remote applications, and it also has support for profiling applications offline.

Let's launch JProfiler and attach the identity service application that we developed in Chapter 9Implementing Microservices with Kotlin:

  1. When JProfiler starts up, the start page is shown, as follows:

  1. We will profile the get organization API of the identity service app.
  2. Select the Attach to a running JVM option. This will list running Java processes. We select our identity service, which is running as follows:

  1. Then it prompts for initial profile settings. Here, we can select Instrumentation or Sampling (Recommended). We choose Sampling (Recommended):

  1. Then we select CPU views and elect to record CPU data, as follow. This starts to capture CPU recordings:

Now, let's execute a load test using Jmeter. We have created simple Jmeter scripts (JMX scripts) to invoke the REST APIs. At this point, we get the JWT token and access the get organization API. We then span five threads, which make concurrent requests to the identity service.

We run the tests for about 10 minutes and capture the CPU recordings. The function call breakdown is captured and shown as follows:

This breakdown shows how much time is spent on each function call.

As we can see, we have profiled a service written in Kotlin. Profiling helps identify performance bottlenecks in code.

..................Content has been hidden....................

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