> For the complete documentation index, see [llms.txt](https://docs.inrupt.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.inrupt.com/ess/administration/scaling.md).

# Scaling

This page discusses horizontal scaling to meet increasing demands.

The page does not cover scaling services such as Kafka, Zookeeper, and PostgreSQL Metrics.

### Horizontal Scaling of ESS

Horizontal scaling of ESS involves adding more worker nodes (VMs) to run additional instances of ESS services; for instance, having 2 instances of Pod Storage service, each running on a separate server, instead of a single Pod Storage service running on one server.

### Scale Services Independently

With ESS, you can scale each service independently of each other. For example, you can have 3 instances of the Pod Storage service and 1 instance of the [Solid OIDC Broker Service](https://docs.inrupt.com/ess/services/advanced-configuration/service-oidc.md).

### Stateless Services

All user-facing ESS services (Pod Storage, etc.) are stateless. Using stateless services strongly supports horizontal scaling as a user’s requests to a given service do not need to route to the same instance of that service.

### Scale a Deployment

You can use [Kustomize Overlays](https://kubernetes.io/docs/tasks/manage-kubernetes-objects/kustomization/#bases-and-overlays) to scale your deployment.

### Example: Scale a Deployment

Adding more Pod provisioning helps with resiliency. The following example file sets the number of replicas for **`ess-pod-provision`** deployment to **`2`** .

1. Go to your ESS installation directory:

   ```sh
   cd ${HOME}/ess
   ```
2. Modify the **`kustomization.yaml`** (i.e., step 3 of the [Applying Your Customizations](https://docs.inrupt.com/ess/installation/customize-configurations.md#applying-your-customizations) procedure).\
   Specifically, add the highlighted content to the **`kustomization.yaml`** file under the **`replicas`** key:

{% hint style="info" %}
**Tip**\
If **`replicas`** key does not exist in **`kustomization.yaml`** , add the key **`replicas`** as well.
{% endhint %}

<pre class="language-yaml"><code class="lang-yaml">
# kustomization.yaml in your ESS installation directory
# ...  Preceding content omitted for brevity 
# ...
replicas:
<strong>- name: ess-pod-provision
</strong><strong>  count: 2
</strong>
</code></pre>

3. Continue with the rest of the [Applying Your Customizations](https://docs.inrupt.com/ess/installation/customize-configurations.md#applying-your-customizations) procedure.

### Database Connections

{% hint style="success" %}
Added in version 3.5.0
{% endhint %}

Each ESS service that uses PostgreSQL limits the number of connections that each of its Pods opens to its database, with **`QUARKUS_DATASOURCE_JDBC_MAX_SIZE`**. The Inrupt-provided manifests set a default for each service.

Before you add Pods, check that your database has enough connections available for the maximum number of Pods of each service. If your database has capacity for more connections, for example when you connect to a larger database instance, you can raise a service's limit with a patch in your overlay. The `env` entry replaces the default by name:

```yaml
# kustomization.yaml in your ESS installation directory
patches:
  - target:
      kind: Deployment
      name: ess-pod-storage
    patch: |-
      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: ess-pod-storage
      spec:
        template:
          spec:
            containers:
              - name: ess-pod-storage
                env:
                  - name: QUARKUS_DATASOURCE_JDBC_MAX_SIZE
                    value: "32"
```
