# High Availability

To enable autoscaling for Temporal services, you need to update the `values/temporal-values.yaml` configuration. This step-by-step guide shows how to configure autoscaling parameters for various Temporal components, including `frontend`, `history`, `matching`, and `worker`.

1. Update the Autoscaling Configuration in `temporal-values.yaml` for Each Temporal Service
   1. **Frontend Configuration:**
      * Modify the `replicaCount`, `autoscaling`, and `resources` sections as follows:

        ```yaml
        frontend:
          replicaCount: 1 # recommended minimum config 2
          autoscaling:
            enabled: true  # Set to 'true' to enable autoscaling(by default false)
            minReplicas: "1"
            maxReplicas: "5"  # Adjust this based on your requirements
            targetCPU: "75"  # Target CPU utilization percentage
            targetMemory: "75"  # Target Memory utilization percentage
          resources:
            requests:
              cpu: 250m
              memory: 512Mi
        ```
      * Setting `autoscaling.enabled` to `true` activates autoscaling for the frontend service. Adjust `minReplicas` and `maxReplicas` according to your expected load and resource availability.
   2. **History Configuration:**
      * Update the `history` service settings:

        ```yaml
        history:
          replicaCount: 1 # Should be set to value of numHistoryShards / 512
          autoscaling:
            enabled: false  #  autoscaling for history not recommended
          resources:
            requests:
              cpu: 500m # recommended 1000m
              memory: 1048Mi # recommended 2048

        ```
      * This configuration ensures the `history` service can scale within the specified limits based on CPU and memory usage.
   3. **Matching Configuration:**
      * Configure the `matching` service:

        ```yaml
        matching:
          replicaCount: 1 # Recommended min config 2
          autoscaling:
            enabled: true  # Enable autoscaling for matching
            minReplicas: "1" # Same as replicaCount
            maxReplicas: "5"  # Adjust this based on your requirements
            targetCPU: "75"  # Target CPU utilization percentage
            targetMemory: "75"  # Target Memory utilization percentage
           resources:
        	   requests:
        			 cpu: 250m
        			 memory: 512Mi

        ```
      * Autoscaling is controlled by the resource thresholds specified. You can adjust these thresholds based on the demand expected on the `matching` service.
   4. **Worker Configuration:**
      * Configure the `worker` service:

        ```yaml
          worker:
            replicaCount: 1 # Recommended min config 2
            autoscaling:
              enabled: false # Enable autoscaling for worker
              minReplicas: "1" # Same as replicaCount
              maxReplicas: "1"  # Adjust this based on your requirements
              targetCPU: "75" # Target CPU utilization percentage
              targetMemory: "75" # Target Memory utilization percentage
            resources:
        	    requests:
        		    cpu: 200m
        			  memory: 512Mi

        ```
      * Autoscaling is controlled by the resource thresholds specified. You can adjust these thresholds based on the demand expected on the `worker` service.
2. Update the Autoscaling Configuration in `nected-values.yaml` for Each Nected Service like vidhaan-executer and vidhaan-router.
   1. **Vidhaan Executer**
      1. Configure the `vidhaan-executer` service:

         ```yaml
         # vidhaan-executer chart to be updated
         vidhaan-executer:
           enabled: true
           replicaCount: 1 # Recommended min config 2
           .
           .
           .

           resources:
             requests:
               cpu: "250m"
               memory: "512Mi"
             limits:
               cpu: "500m"
               memory: "1024Mi"

           autoscaling:
             enabled: false # Enable autoscaling for executer
             minReplicas: 1
             maxReplicas: 1
             targetCPUUtilizationPercentage: 80
             targetMemoryUtilizationPercentage: 80

         ```
   2. **Vidhaan Router**
      1. Configure the `vidhaan-router` service:

         ```yaml
         # vidhaan-router chart to be updated
         vidhaan-router:
           enabled: true
           replicaCount: 1 # Recommended min config 2
           .
           .
           .

           resources:
             requests:
               cpu: "250m"
               memory: "512Mi"
             limits:
               cpu: "250m"
               memory: "1024Mi"

           autoscaling:
             enabled: false # Enable autoscaling
             minReplicas: 1
             maxReplicas: 1
             targetCPUUtilizationPercentage: 80
             targetMemoryUtilizationPercentage: 80
         ```

Autoscaling is controlled by the resource thresholds specified. You can adjust these thresholds based on the demand expected on the `matching` service.


---

# 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.nected.ai/nected-docs/self-hosting/additional-configuration/high-availability.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.
