Memory of the app
This page says how much memory the management app gets, how it uses it, and when to give it more. It concerns the app (the web UI and the management API). The Topics, GraphRAG Topics and Agents are separate containers, see section 5.
1. What the files set
| Default | |
|---|---|
Memory limit of the app container |
4 GB. Docker Compose: |
Working memory the app takes from it |
70 % ( |
When the app runs out of memory |
It stops, and the container is started again by Docker ( |
The remaining 30 % (about 1.2 GB with the default) is for everything that is not working memory: the stacks of the threads, the buffers of network connections and the program itself. Every chat in the web UI that is being answered needs threads and buffers of its own, so this part grows with the number of people who chat at the same time. This is why the share is 70 % and not more.
|
Keep a memory limit on the container. The app sizes its working memory as a share of the memory it sees. With a limit, that is the limit. Without one, it is the memory of the whole host, and the app may take most of it from the other programs on that host. |
2. Who needs more
Chats that run through the web UI use the memory of the app. Chats that your own programs send directly to a Topic or Agent over its REST interface do not run through the app. They use the memory of the Topic or Agent container, and only little of the app.
-
Few users in the web UI, for example administrators who test: the default is enough.
-
Many people use the chat in the web UI at the same time: give the app more memory. We have not measured a number of users per gigabyte yet, so start with the signs below and raise the limit step by step.
Signs that the app has too little memory:
-
The app container restarts by itself. Look at
docker psorkubectl -n aiknowledgefabric get podsfor the restart count. -
The log of the app, shortly before a restart, contains
java.lang.OutOfMemoryError. -
Pages and chats become slow when many people are active, and
docker statsshows the container near its limit.
3. How to give the app more memory
Docker Compose. Add a line to your .env file and recreate the app (docker compose up -d):
APP_MEMORY_LIMIT=8g
Kubernetes. Change the limit in deployment.yaml and apply the file again:
resources:
requests:
memory: "2Gi"
limits:
memory: "8Gi"
The working memory follows the limit: 70 % of 8 GB is about 5.6 GB. You do not need to set anything else.
4. How to change the share
Change the share only if you know why. A higher share leaves less for threads and buffers, and the container can then be stopped by the host for using too much memory, even though the working memory is not full. A lower share does the opposite.
The settings are in the variable JAVA_TOOL_OPTIONS. Setting it replaces the whole default value, so write both
parts:
JAVA_TOOL_OPTIONS=-XX:MaxRAMPercentage=60 -XX:+ExitOnOutOfMemoryError
Put it in .env for Docker Compose, or under env: of the container in deployment.yaml for Kubernetes.
-XX:+ExitOnOutOfMemoryError is the part that makes the app stop on an out-of-memory error, so that it is restarted.
5. Topics, GraphRAG Topics and Agents
-
Docker: the containers that the app starts have no memory limit. They use what they need from the host.
-
Kubernetes: the app gives each pod a limit: 2 Gi for a Topic, 2 Gi for a GraphRAG Topic and 1 Gi for an Agent (
K8S_TOPIC_MEMORY_LIMIT,K8S_GRAPHRAG_MEMORY_LIMITandK8S_AGENT_MEMORY_LIMIT, see Installing on Kubernetes). These images still use the Java default for their working memory, a quarter of the limit. If a Topic or Agent runs out of memory under load, raise its limit.