# Performance issues

In case of performance issues, you may try the following:

* Review the [Server host requirements](/sonarqube-server/server-installation/server-host-requirements.md) for SonarQube Server linked to **Elasticsearch** usage.
* Move the Elasticsearch storage to a storage with high IOPS and low latency. See [Basic installation](/sonarqube-server/server-installation/from-zip-file/basic-installation.md#configure-es-storage-path) for more information.
* Set the [Housekeeping](/sonarqube-server/instance-administration/system-functions/housekeeping.md) with a reduced retention time, to limit the database size.
* Configure the analysis scope to reduce the number of files analyzed, leading to shorter analysis and smaller database footprint. See [Introduction](/sonarqube-server/project-administration/adjusting-analysis/setting-analysis-scope/introduction.md) for more information.
* From the [Enterprise Edition](https://www.sonarsource.com/plans-and-pricing/enterprise/): increase the number of Compute Engine workers and/or configure the Compute Engine to enable parallel processing of pull requests and branch analyses for each project. See [Improving performance](/sonarqube-server/server-update-and-maintenance/maintenance/improving-performance.md).
* For the Data Center Edition on Kubernetes: set up autoscaling. See [Setting up autoscaling](/sonarqube-server/server-installation/data-center-edition/on-kubernetes-or-openshift/setting-up-autoscaling.md) for more details.
* If performance issues occur after a PostgreSQL database upgrade, try reindexing the following database tables: issues, rules, and components.

## Troubleshooting background tasks processing problems

You detected one of the following conditions:

* Background tasks have been waiting in the queue longer than expected
* Too many tasks are pending in the queue
* A high share of background tasks are failing

All three signal the same class of problem: the Compute Engine (CE) is unable to process analyses at its normal rate. This guide walks you through diagnosing and fixing the most common causes.

### Step 1. Understand what is happening

Go to **Administration** > **Background Tasks** to see the current queue state:

* How many tasks are pending and how long the oldest one has been waiting
* Whether tasks are failing, and if so, which projects

Go to **Administration** > **System** to check the health of the Compute Engine, Web, and Search nodes.

If tasks are failing, click on a failed task to read the error message, this often points directly to the cause.

### Step 2. Check heap size

In `sonar.properties` (or environment variables), verify:

* `sonar.ce.javaOpts` contains an `-Xmx` value of at least 512 MB per worker.
* `sonar.ce.workerCount` × per-worker heap ≤ total RAM available after Web and Search allocations

Correct sizing:

| Web          | 1–2 GB (do not exceed 2 GB)     |
| ------------ | ------------------------------- |
| CE           | 512 MB–2 GB × number of workers |
| Search (DCE) | 2–4 GB                          |

If you recently increased `sonar.ce.workerCount` without adjusting `sonar.ce.javaOpts`, that is almost certainly the cause. Reduce the worker count or increase Compute Engine heap, then restart.

Maven scanner users: If you upgraded the SonarQube Maven plugin to v5.0 or later, `MAVEN_OPTS` no longer controls scanner heap. Use `SONAR_SCANNER_JAVA_OPTS` instead.

### Step 3. Check database performance

Database I/O problems are the second most common cause.

Check `ce.log` for slow steps. If you see any of the following taking more than a few minutes, the database is the bottleneck:

* `Persist issues`
* `Persist live measures`
* `Execute component visitors`

[Run database maintenance](https://docs.sonarsource.com/sonarqube-server/server-update-and-maintenance/update/pre-update-steps#recommended-database-maintenance-steps) if it has not been done recently.

Also check storage write latency, SonarQube requires < 10 ms per write transaction. NFS or EFS mounts and spinning disks do not meet this requirement.

### Step 4. Check for a large project blocking the queue

A single project with tens of thousands of components can monopolize Compute Engine for 30-60+ minutes. In **Administration** > **Background Tasks**, look for one task that has been running much longer than the others.

If found:

* Consider cancelling it and re-triggering after fixing heap or DB (see steps 2-3)
* Review sonar.exclusions in that project's settings, generated code, test fixtures, dependencies, and build artifacts should be excluded

### Step 5. For Data Center Edition

* Verify every application node has at least one CE worker configured. A single shared worker across the cluster will cause queue buildup.
* After a rolling restart, confirm all nodes have rejoined the Hazelcast cluster (**Administration** > **System** > **Cluster**) before triggering new analyses.
* If you see *Task does not exist anymore* errors, this is a known race condition, failed tasks can safely be re-triggered.

### Still not resolved?

[Contact support](/sonarqube-server/server-update-and-maintenance/troubleshooting/creating-support-ticket.md).

## Adjusting alert thresholds

For Monitoring alerts the default thresholds can be changed at any time without restarting the instance. See [Monitoring alerts](/sonarqube-server/server-update-and-maintenance/monitoring/monitoring-alerts.md) for more information.

## Related pages <a href="#related-pages" id="related-pages"></a>

* [Server logs](/sonarqube-server/server-update-and-maintenance/troubleshooting/server-logs.md)
* [Database-related issues](/sonarqube-server/server-update-and-maintenance/troubleshooting/database-related-issues.md)
* [Elasticsearch-related issues](/sonarqube-server/server-update-and-maintenance/troubleshooting/elasticsearch.md)
* [Other issues](/sonarqube-server/server-update-and-maintenance/troubleshooting/other-issues.md)
* [Improving performance](/sonarqube-server/server-update-and-maintenance/maintenance/improving-performance.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sonarsource.com/sonarqube-server/server-update-and-maintenance/troubleshooting/performance-issues.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
