Facing issue in RAM utilization in DHIS2 version 2.40.4 due to postgres

We are in the process of migrating our data to the DHIS2 platform using the API. During this process, we encountered an issue where the Tomcat service suddenly stopped, resulting in a 502 Bad Gateway error on the browser.

Upon further investigation, it was found that the RAM utilization exceeded 97%, causing the Tomcat service to stop. Additionally, several PostgreSQL processes on the server were in an idle state for more than 2-3 hours. After restarting the PostgreSQL services, the RAM utilization dropped to only 500MB out of 16GB.

Do we have any solutions to manage RAM utilization more effectively and to automatically kill idle PostgreSQL processes to prevent this issue from recurring?

1 Like

Hi @kandarpjoshi

First, it is good that you were able to uncover the issues and what’s causing them.

Have you tried to configure the API requests differently? For example, if the data can be transferred in parts rather than in one API request…

1 Like

@kandarpjoshi

Are you using a recent version of Postgres? In the installation documentation it is recommended to set this jit = off on postgres configuration file for version 12 and upwards.
I’ve experienced a kinda of a similiar of having several Postgres processes in iddle when running program indicators, and this fixed it for me.

Best regards