Schedule demo

Thread Profiling


Overview

Thread profiling enables you to identify and isolate bottlenecks in your code stack. In Applications Manager's APM Insight, all thread profiles collected in the chosen time window are listed, along with the thread count, CPU time and memory details. Each thread profile consists of a list of threads that were running when the application was being profiled.

Upon clicking a specific thread profile, one can view:

  • High CPU consuming threads,along with its thread ID, CPU time and memory allocated details
  • Time consuming methods which could potentially affect application's performance
  • Invocation count of every method

Once profiling is done, the generated dumps can be analysed in GUI. Check out the Thread Dump Analysis feature to explore more.

Automated Thread Profiling can be configured as an action to capture thread profiles for APM Insight Java/.NET Application Monitors when an alarm is triggered. Learn more

Viewing thread profiles

To view Thread Profiles,

  1. Log into your Applications Manager account.
  2. Go to APM tab and click on your application.
  3. Click on Thread Profiling tab and then click on individual threads to inspect them further.

Note: Thread profiling is supported only for JAVA and .NET agents.

Types of thread profiling

  1. Scheduled profiling
  2. On-Demand profiling

Scheduled profiling

APM Insight schedules thread profiling twice a day for a period of 5 minutes.

Note:

  • In Java agent, scheduled thread profiling happens for every one hour.
  • Scheduled profiling is enabled for Java agent by default, and is not supported for .NET agent.
  • Scheduled profiling is done for agent's internal purpose.
  • For Java agent, scheduled profiling can be enabled by adding the below property in apminsight.conf file: thread.profiling.enabled=true
  • After implementing the above changes, save and close the file. Now scheduled profiling will happen for every one hour.

On-Demand profiling

With On-Demand profiling, one can initiate thread profiling at the current time for a duration ranging from 5 to 30 minutes. The threads are sampled at regular time interval in the specified duration and the collective data is displayed at the end of time duration.

To initiate On-Demand profiling,

  • Log into your Applications Manager account.
  • Go to APM tab and click on your application.
  • Click on Thread Profiling tab, then click on On-Demand thread profiling tab to initiate.
  • Specify time duration and click on Initiate profiling.

Note: On-Demand profiling can be initiated only once per hour (i.e) if you initiate On-Demand profiling for 5 minutes, next initiation can be done only after 55 minutes.

On-Demand profiling can be initiated for both applications and instances.

  • In application view, On-Demand profiling will be initiated for all the available instances of that application.
  • In instance view, On-Demand profiling will be initiated only when the instance is UP.
  • When your instance is suspended, On-Demand profiling will be disabled.
Note: When you initiate thread profiling from the Application view, it activates across all instances within that application simultaneously.

Top N resource-consuming threads

With this option, you can easily identify the threads that consume the most CPU or memory. You can choose any value (N) from five to 20.

Note: This option is only available for Java agents v6.0 and above.

Applications Manager APM Insight: Thread profiling configuration for Top N resource-consuming threads

When ON-DEMAND thread profiling is requested, the agent also monitors the CPU and memory usage of each thread. The agent picks the top N threads that consumed a large amount of resources from each category (CPU and memory) based on the N value you provided. Once the profiling is finished, the threads, along with their usage statistics and stack traces, will be displayed in the Applications Manager web client.

The below figure shows the threads sorted in descending order by the amount of resources consumed.

Applications Manager APM Insight: Thread profiles in monitor page

The left pane lists the thread profiles collected in the selected time range, along with the number of threads captured in each profile and the time at which profiling started. Click a thread profile to view its details.

The summary at the top of the page shows the following details:

MetricDescription
CPU TimeThe average CPU time consumed per thread in the profile. Min and Max show the lowest and highest CPU time consumed by a single thread (in ms or sec).
Thread CountThe number of threads captured in the profile.
Memory UsageThe average memory allocated per thread in the profile. Min and Max show the lowest and highest memory allocated by a single thread (in bytes, KB, MB, or GB).
Profiling DurationThe duration for which the threads were profiled (in minutes).

The Top threads by resource utilization tab lists the following details for each thread:

ColumnDescription
Thread IdThe unique ID assigned to the thread by the JVM. Use this ID to identify the same thread in a thread dump.
Thread NameThe name given to the thread by the application, framework, or application server. The name usually indicates the role of the thread. For example, http-nio-9097-exec-3 is a Tomcat request processing thread for the connector on port 9097, and Thread-23 is the default name the JVM assigns to a thread created without a name.
CPU TimeThe total CPU time consumed by the thread during the profiling duration (in ms or sec). Click the column header to sort the threads by CPU time.
Memory UsageThe memory allocated for the thread since JVM start (in bytes, KB, MB, or GB).

Use the search icon to find a thread by its ID or name.

Click the arrow next to a thread to expand its Stacktrace. The stack trace lists the method calls the thread was executing when it was sampled. The topmost entry is the method that was running, and each entry below it is the method that called the one above it, down to the thread's entry point (for example, java.lang.Thread.run). Each entry shows the fully qualified class and method name, followed by the source file name and line number, for example, java.util.concurrent.LinkedBlockingQueue.take (LinkedBlockingQueue.java:442).

Note:

  • A thread with high CPU time whose stack trace points to your application's classes is a likely performance bottleneck. Check the topmost application method and line number to find the code to optimize.
  • A thread whose topmost entries are waiting methods, such as sun.misc.Unsafe.park or LinkedBlockingQueue.take, is idle and waiting for work, not actively consuming CPU at the time of sampling.

Loved by customers all over the world

"Standout Tool With Extensive Monitoring Capabilities"

★★★★★

It allows us to track crucial metrics such as response times, resource utilization, error rates, and transaction performance. The real-time monitoring alerts promptly notify us of any issues or anomalies, enabling us to take immediate action.

Reviewer Role: Research and Development

carlos-rivero
"I like Applications Manager because it helps us to detect issues present in our servers and SQL databases."
Carlos Rivero

Tech Support Manager, Lexmark

Trusted by thousands of leading businesses globally