From documentation " DHIS2 requires that your server has an appropriate amount of RAM.
RAM based on the type of the instance: At least 2 GB for a small instance, 12 GB for a medium instance, and 64 GB or more for a large instance "
We would like to understand the various factors we should considering (like DB size/number of users)to know which type does our instance come under to enable us to decide on the RAM size.
Generally I would say this advice is a little vague (and dated). In the past we had quite a lot of cases of API calls which allocated large amounts of memory. This would cause tomcat to fall over and be quite unstable under certain types of load. Over the past few years these have been reduced quite dramatically and tomcat generally will run well with much more humble amounts of RAM. I would say 16G would be quite adequate for most national HMIS instances for example. If you have a limited pool of RAM to allocate, you will in most cases get better value giving it to the database server. I think the main factor to bear in mind is number of users. So instances with many thousands of users (eg large android installed base), you would likely need more RAM (or horizontally scale with multiple tomcats, though this adds some complexity). The most important thing to do is to ensure that your instance is properly monitored, to understand resource usage under load. A tool like https://glowroot.org is essential to ensure that you are not flying blind. Somewhat ironically, the first indication of RAM problems is usually excessive CPU usage. A closer look at this reveals that the CPU might be spending 90% of its time doing garbage collection to relieve its memory stress.