0

I know about the concept of "Free RAM is wasted RAM". My question is how quickly and efficiently the OS can free up the cached RAM, so that apps have enough RAM in time of a spike in usage.

We have a web app hosted in linux. We normally have 10-20% memory utilisation. But we see spikes up to about 100% when certain parts of the code is invoked.(Code has been max optimised).I want to trigger an email when this happens. Should I write a script to monitor memory utilisation including Cache or just the application memory ?

When the Out of Memory error occurs in linux, does it means cache memory is zero and all the RAM has been already allocated to applications ?

  • 2
    In comparison to a network connection, the time taken to make cached memory available to a program in negligible. What issue do you have? – Kusalananda Oct 9 '17 at 7:44
  • What is that web app? Say much more about it. In what programming language? If in a compiled language, how exactly was it compiled? Better put more efforts on improving the app, or get more resources (buy more RAM), than in just coding a script to detect the situation. Do you know what exact part needs so much memory? – Basile Starynkevitch Oct 9 '17 at 10:31
0

How quickly and efficiently the OS can free up the cached RAM, so that apps have enough RAM in time of a spike in usage?

Unless you are using ZFS on Linux with which the ARC might not shrink fast enough to absorb a sudden RAM demand, the time spent by the kernel to free the caches is negligible, as already commented by Kusalananda.

Should I write a script to monitor memory utilisation including Cache or just the application memory ?

I would monitor both the application memory and the system one. When the cache is reduced to make room for application memory, performance might drop because more disk I/Os are required.

When the Out of Memory error occurs in linux, does it means cache memory is zero and all the RAM has been already allocated to applications ?

When an out of memory occurs, most buffers/cache has been freed/flushed but that doesn't mean all the memory is used by applications. A part of the memory is still used by the kernel, and possibly a ram based file system or directly by some hardware.

  • Will the condition (app memory + cache) > 95 % occur often or only in case of usage spikes ? – Jibin Oct 9 '17 at 14:00
  • That entirely depends on the configuration, the overall I/O usage on your machine and the running applications behavior. – jlliagre Oct 9 '17 at 15:25
  • Would you please care to explain – Jibin Oct 10 '17 at 5:30
  • I mean there is no rule, that might happen very quickly, rarely or never, depending on the installed RAM and what your applications are doing with the disk, the disk size and how much of it is accessed. The simpler way to figure it out is for you to monitor your system and see how RAM usage evolves. – jlliagre Oct 10 '17 at 6:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.