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
  • 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, 2017 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? Oct 9, 2017 at 10:31

1 Answer 1

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.

4
  • Will the condition (app memory + cache) > 95 % occur often or only in case of usage spikes ?
    – Jibin
    Oct 9, 2017 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, 2017 at 15:25
  • Would you please care to explain
    – Jibin
    Oct 10, 2017 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, 2017 at 6:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .