I have Apache +Mysql+ PHP installed on 4G memory server which serve around 20000 visits per day. The following graph shows the memory utilization for one day. As you can see from the graph: the free memory is low (e.g 155 M) and the cached memory is high (e.g 2G). This server did not use the swap memory ever.
- do I need to increase the memory?
- Is it safe to have low free memory but high cached memory?
- How do I find which application using a lot of cache memory?
The
cached
memory is the disk cache used by theVFS
. It will store files that are read there so that it does not have to hit the hard drive when they are needed, and if some application need memory, it will release some.The questions you should ask yourself are :
If both answers are no, then, you don't need to do anything. Even if some applications get swapped out a bit, it may be because the part that has been swapped is never used and can safely be stored on swap.
The idea is that as long as everything's working fine, don't try to fix it, cached memory, and even swapping out pages is the normal operation of a VM operating system.
Your question was not specific, but I am going to assume the system running apache is Linux-based. Cached memory is memory used by the kernel for caching files. This is generally a good thing, and normal. Having memory in your system that does nothing is silly when it could be doing something useful like speed up access to your files.
As stated above, the cached memory is just an in memory (fast) buffer for the data stored on your hard disks (slow). You will typically see that if the used memory (by your applications) increases, the cached count will decrease. So this looks like a fairly normal graph to me.
Another parameter you should keep into account is the swap usage, as soon as your system is starting to use swap (which is on disk memory and thus slow) it means that your system is running sub-optimal and this suggest the addition of physical memory.
Actually should be happy in this case that your operating system is making such efficient use of your memory (by using it as disk cache), it would be rather pointless to read/write everything to disk (which is slow) while you have ram a la plenty sitting around not being used for anything.