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

Contents:

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.
  • By default, Scheduled profiling is disabled for Java agent and is not supported for .NET agent.
  • 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 the first available instance.
  • 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.

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.

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.