I am seeking detailed information on the following questions:
What is a containerized environment (containers) with regards to DHIS2 components: PostgreSQL, JDK, JRE, Tomcat, reverse proxy etc)?
How is memory allocation managed for each component? Where to allocate much memory? E.g in a case there are 8000 users (most of them Android Users) for tracker data
In which case might we have out of memory error in relation to each component and which steps to take?
With regard to containerization and DHIS2, we typically encourage the use of LXD. We also have user-friendly tools developed with Ansible, which you can find on GitHub: GitHub - dhis2/dhis2-server-tools: Tools to support installation and management of DHIS2. These tools are highly flexible for automated containerization. If you’re familiar with Ansible, it provides variables where you can configure how much memory each container can use. We’ve had meetings discussing this type of automation, and you can find the recordings here: 2024-Weekly-meet-ups - Google Drive. We highly encourage you to attend these weekly meetings to learn more.
If you plan to go the standalone installation a few thing you need to keep in my are as follows:
In a containerized environment, memory allocation for each component is managed through container limits (set using Docker, LXD or Kubernetes). You can specify how much memory and CPU resources a container can use, helping prevent one component from monopolizing resources.
PostgreSQL will require a significant amount of memory, especially with 8,000 users, many of whom are using tracker programs that generate a lot of data.
DHIS2 runs on Java, and the JVM needs sufficient memory to perform well. Allocate 50-60% of the total available RAM to the JVM heap (adjusted based on your environment). For a large tracker instance with 8,000 users, start with at least 32 and 64GB for the JVM heap size minimum 16GB.
Tomcat uses the same heap memory as the JVM (since it’s running Java). It’s crucial to optimize the heap size for Tomcat as it handles many requests from the Android users.
Reverse proxies like Nginx or Apache HTTP server require significantly less memory than the other components. They handle HTTP requests and forward them to Tomcat but are not resource-intensive maybe 1 to 2GB would work.
An Out of Memory (OOM) error occurs when a system or application component exceeds its allocated memory limit, causing a failure or crash. In a DHIS2 environment, OOM errors can arise from components like PostgreSQL (due to insufficient cache or large queries), the JVM/Tomcat (from running out of heap memory during data processing), or even reverse proxies (rare, but possible with high traffic or small buffer sizes). To prevent OOM errors, it’s essential to allocate enough memory for each component, optimize garbage collection, monitor resource usage, and ensure proper tuning of parameters like heap size, shared buffers, and Metaspace.
Your explanation is so clear.
one more question: for a DHIS 2 system that will be processing a large volume of requests from thousands of users, what are the most recommended physical server specifications in relation to RAM, CPU, Storage, etc.
I have been tasked with providing server specifications for my company.
In the past year, I faced a similar situation where my server provider requested specific numbers for the system specifications
To ensure flexibility, deploy the system using virtualization technologies like VMware, or in a cloud environment (AWS) where resource scaling (RAM, CPU, storage) can be done dynamically.
quick summary , as per your demand and increases specification
RAM: 32 GB (min), 64 GB+ (recommended)
CPU: 8 cores (min), 16 cores+ (recommended)
Storage: 500 GB SSD (min), 1 TB SSD+ (recommended, NVMe preferred), if image and 2 TB, maintain logs on external server