Troubleshooting Confluence performance issues with thread dumps
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Problem
Confluence is behaving slowly, and you need more information as to what part of it is being slow. You may have also noticed that the CPU usage on your application server is very high.
This page provides a way of collecting thread dumps (a breakdown of what every thread is doing for a Java process) and the output of top (shows what each native OS thread is consuming as far as resources are concerned). This breakdown could normally be collected with something like jProfiler or other options, as discussed here. In this example we're using native (free) tools to collect information.
This will only work for *nix systems and needs jstack
to be installed (should be by default). For Windows please see Generating thread dumps on windows or Generating a Thread Dump.
Capturing CPU Diagnostics
Resolution
Run the following command to find your Confluence instance. If this returns multiple results, then you have more than one Tomcat instance running on your machine. You'll need to identify your Confluence instance from these results manually:
ps aux | grep -i catalina.startup.Bootstrap
Set the variable
CONF_PID
to the process ID returned. This will be the second field from Step 1:
CONF_PID=<your_process_id>
After the
CONF_PID
variable is set, execute the following script with the user running the Confluence application. The script will generate 6 sets of CPU usage info and thread dumps at 10 seconds intervals, running for a total of 60 seconds:Option 1 - JSTACKfor i in $(seq 6); do top -b -H -p $CONF_PID -n 1 > conf_cpu_usage.`date +%s`.txt; jstack -l $CONF_PID > conf_threads.`date +%s`.txt; sleep 10; done
Option 2 - KILL -3for i in $(seq 6); do top -b -H -p $CONF_PID -n 1 > conf_cpu_usage.`date +%s`.txt; kill -3 $CONF_PID; sleep 10; done
If this gives you the error
"Unable to open socket file: target process not responding or HotSpot VM not loaded
", or if any of the files generated are completely empty, please make sure you're executing this script as the same user that started your Confluence process.
Reading CPU Diagnostics
Two types of files will be generated by the script:
- CPU usage info - this shows how much CPU each Confluence thread is consuming at that snapshot in time
- Thread dump - this shows what is thread was doing at that snapshot in time
Looking at both sets of data together can help locate a problematic process:
Look in the resulting CPU usage files to identify which threads are consistently using a lot of CPU time.
Take the PID of the top threads which are using CPU time and convert them to Hexadecimal. Eg: 11159 becomes 0x2b97.
Search for the Hex values in the thread dumps to figure out what these high-CPU threads are doing.
Performance Data Collector
See How to use the Performance Data Collector for more information.