> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-delivery/use-gitops/gitops-entities/agents/agent-argocd-performance.md).

# Performance Considerations

Learn how to improve performance with your Argo CD deployments

Argo CD manages continuous deployments in Kubernetes environments. As deployments scale, you might encounter performance challenges, particularly with the **Application Controller** and **Repository Server** components. Understanding these common issues helps you maintain optimal performance.

Scaling issues can arise from high resource consumption, slow application refresh rates, and challenges with monorepos. Many issues have been resolved in newer versions of Argo CD, so Harness recommends keeping your Argo CD version up to date.

The nature of these issues depends on your environment and use case, so there is no single general solution. Monitor the Argo CD components and your environment, and review the following common issues and solutions.

***

## Application Controller performance issues

Review the following causes and solutions for common Application Controller performance issues.

1. **High CPU and Memory Usage**:
   * **Cause**: Managing a Kubernetes cluster with a large number of objects can lead to increased resource consumption. For instance, in environments with numerous applications, the Application Controller may experience elevated CPU usage, leading to performance degradation.
   * **Solution**: Scaling up the Application Controller by increasing the number of replicas can help distribute the workload and improve performance. Go to [Argo CD high availability](https://argo-cd.readthedocs.io/en/stable/operator-manual/high_availability) to review scaling guidance. You can also dedicate each application pod to one cluster, known as sharding. Go to [Argo CD scaling operations](https://kostis-argo-cd.readthedocs.io/en/first-page/operations/scaling/#common-scaling-problems) to review common scaling problems.
   * **Cause**: Applications with self-heal enabled can cause high CPU usage when the application continually differs from its desired state.
   * **Solution**:
     * Use exponential backoff for the application sync. Edit the `argocd-cmd-params-cm` ConfigMap:

       ```bash
       kubectl edit configmap argocd-cmd-params-cm -n argocd
       ```

       ```yaml
       data:
         controller.self.heal.timeout.seconds: "2"          # Initial delay between self-heal attempts (in seconds)
         controller.self.heal.backoff.factor: "3"           # Multiplier for exponential backoff
         controller.self.heal.backoff.cap.seconds: "300"    # Maximum delay cap (in seconds)
       ```
     * Go to [Argo CD diff customization](https://argo-cd.readthedocs.io/en/latest/user-guide/diffing/) to ignore diffs on certain fields.
2. **Slow Application Sync Time**:
   * **Cause**: A large number of applications or resources can slow down the application sync process, leading to delays in reflecting changes.
   * **Solution**:
     * Adjusting the `--status-processors` and `--operation-processors` settings allows for more concurrent processing, improving refresh rates. Go to [Argo CD: Application Controller](https://argo-cd.readthedocs.io/en/stable/operator-manual/high_availability/#argocd-application-controller) to review tuning guidance for large-scale deployments.
     * Enabling the `----kubectl-parallelism-limit` flag can also speed up the application sync process by allowing more concurrent operations.
     * Increase the `timeout.reconciliation` value to allow more time for reconciliation when you have a large number of applications.
     * Change `ARGOCD_K8S_CLIENT_QPS` and `ARGOCD_K8S_CLIENT_BURST` to increase the Kubernetes API client QPS and burst QPS (the default values are 50 and 100, respectively). When you change these values, monitor the Kubernetes API server to confirm it can handle the increased load.
     * Apply the following configuration to the `argocd-application-controller` StatefulSet to set these values:

       ```yaml
       apiVersion: apps/v1
       kind: StatefulSet
       metadata:
         name: argocd-application-controller
       spec:
         template:
           spec:
             containers:
               - name: application-controller
                 env:
                   # Setting for changing the client qps
                   - name: ARGOCD_K8S_CLIENT_QPS
                     value: "50"
                   # Setting for changing the burst qps
                   - name: ARGOCD_K8S_CLIENT_BURST
                     value: "100"
       ```

***

## Repository Server performance issues

Review the following causes and solutions for common Repository Server performance issues.

1. **Out-of-Memory (OOM) Errors**:
   * **Cause**: The Repository Server is responsible for cloning repositories and generating manifests. High concurrency during these operations can lead to excessive memory consumption, causing OOM errors.
   * **Solution**: Configuring the `--parallelismlimit` flag controls the number of concurrent manifest generations, preventing resource overuse. Go to [Argo CD high availability](https://argo-cd.readthedocs.io/en/stable/operator-manual/high_availability) to review scaling guidance.
2. **Monorepo Challenges**:
   * **Cause**:
   * **Solution**: Enabling concurrent processing by creating a `.argocd-allow-concurrency` file in the application directory allows for parallel manifest generation, mitigating delays. Go to [Argo CD high availability](https://argo-cd.readthedocs.io/en/stable/operator-manual/high_availability) to review scaling guidance.

***

## HPA and monitoring

By default, Harness enables Horizontal Pod Autoscaling (HPA) for the `argocd-repo-server` and `gitops-agent` components.

```yaml
spec:
  maxReplicas: 5
  metrics:
  - resource:
      name: memory
      target:
        averageUtilization: 50
        type: Utilization
    type: Resource
  - resource:
      name: cpu
      target:
        averageUtilization: 50
        type: Utilization
    type: Resource
  minReplicas: 1
```

{% @harness-feedback/feedback %}
