# Limit docker container RAM usage

With the release of Helmut 4.8.x and the corresponding update to the Java environment, it is now possible to limit the maximum amount of RAM a container can allocate.

Setting memory limits for containers helps ensure predictable resource usage and protects the host system from excessive memory consumption.

Many modern runtimes, including Java, use garbage collection (GC) to manage memory allocation. These mechanisms generally behave more predictably when a memory boundary is defined. Without a defined limit, a container may continue allocating memory as long as the host system has available RAM.

In such situations, a single container could consume large amounts of memory and potentially impact the performance or stability of other containers running on the same host.

More information about garbage collection can be found here:\
<https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)>

### **New Helmut4 Installation**

By default, this RAM limitation setting is included in every new Helmut4 installation, whether it is deployed as a single server or a cluster system.

The RAM limits are defined as default parameters in the stack YAML file.

### **Updating Existing Helmut4 Installations**

Existing Helmut4 installations can be updated to use the same resource allocation settings. To implement this change, users need to update the stack YAML configuration.

You can download the default stack YAML file from our repository for reference:

* **Single Server:** <https://repo.moovit24.de/install/config/docker-compose.yml>
* **Cluster System:** <https://repo.moovit24.de/install/config/docker-compose-swarm.yml>

{% hint style="info" %}

## Environment-Specific Adjustments

Please note that these values may need to be adjusted depending on your system requirements.

For example, systems with high **I/O activity or CPU load** may require additional memory for related containers such as **io**, **co**, or **mongodb**.
{% endhint %}

#### Example

Below is an example configuration showing a RAM limit for the language container:

<figure><img src="https://content.gitbook.com/content/cJYkTyk9qgh7aCR6dHIm/blobs/YWFzIio0uwCsCUEczeGm/image.png" alt="" width="563"><figcaption><p>language image with ram limit</p></figcaption></figure>

<details>

<summary>Generic resource configuration template</summary>

Single Server

```yaml
deploy:
   resources:
      limits:
         memory: 250M
```

Cluster Server

```yaml
deploy:
   mode: global
   #mode: replicated
   resources:
      limits:
         memory: 250M
```

</details>

### **Default RAM limits**

The following values can be considered as defaults:

{% hint style="info" %}

## Environment-Specific Adjustments

The following values can be considered default recommendations.

Please note that these values may need to be adjusted depending on your system requirements. For example, systems with high I/O and CPU workloads might require increased memory for containers such as io, co, and mongodb.
{% endhint %}

| Container / Image                                                                                           | Memory (MB) |
| ----------------------------------------------------------------------------------------------------------- | ----------- |
| traefik                                                                                                     | 250         |
| hp                                                                                                          | 300         |
| hw                                                                                                          | 300         |
| fx                                                                                                          | 1500        |
| io                                                                                                          | 2000        |
| co                                                                                                          | 2000        |
| hk                                                                                                          | 1500        |
| users                                                                                                       | 1500        |
| streams                                                                                                     | 2000        |
| preferences                                                                                                 | 400         |
| metadata                                                                                                    | 350         |
| logging                                                                                                     | 350         |
| amqp                                                                                                        | 250         |
| license                                                                                                     | 400         |
| language                                                                                                    | 350         |
| cronjob                                                                                                     | 300         |
| mongodb / mongodbrs                                                                                         | 4000        |
| mongodb\_backup                                                                                             | 1000        |
| mongodb\_admin/express                                                                                      | 250         |
| rabbitmq                                                                                                    | 2000        |
| hc ([linux client](https://docs.helmut.de/helmut4-releases/installation-guide/helmut4-client#linux-client)) | 2500        |
