Hi,
A few days ago I checked the health of my main public server running CentOS 7, a quad-core machine with 16 GB RAM. It had been running non-stop for 65 days, hosting only a handful of services (BIND, NTP, Apache, Postfix, Dovecot) for two domains.
I was surprised to see that RAM consumption was relatively high, and apparently, the machine even had to swap at some time.
I read up a bit on RAM consumption, and now I wonder if flushing the memory cache regularly is a good idea.
https://tecadmin.net/flush-memory-cache-on-linux-server/
Any suggestions?
Niki
On 09/09/17 12:43, Nicolas Kovacs wrote:
Hi,
A few days ago I checked the health of my main public server running CentOS 7, a quad-core machine with 16 GB RAM. It had been running non-stop for 65 days, hosting only a handful of services (BIND, NTP, Apache, Postfix, Dovecot) for two domains.
I was surprised to see that RAM consumption was relatively high, and apparently, the machine even had to swap at some time.
Why were you surprised? Linux systems use the available RAM, surely you understand that?
Of course there is the possibility that you have discovered a bug and there is a memory leak on your system, building up over time. I suggest you show the list full memory usage details if you feel this is the case.
I read up a bit on RAM consumption, and now I wonder if flushing the memory cache regularly is a good idea.
https://tecadmin.net/flush-memory-cache-on-linux-server/
Any suggestions?
Did you read the kernel documentation on the subject linked in comments section of that article?
Niki
Le 09/09/2017 à 14:41, Phil Perry a écrit :
Why were you surprised? Linux systems use the available RAM, surely you understand that?
I'm surprised because my system used the available RAM and then it even began to swap.
Of course there is the possibility that you have discovered a bug
Minimal CentOS 7 installation with BIND, Apache, MySQL, Postfix and Dovecot, regularly updated.
Hence my post. Wondering if other CentOS users experienced something similar.
Niki Kovacs
On 09/09/2017 07:55 AM, Nicolas Kovacs wrote:
Le 09/09/2017 à 14:41, Phil Perry a écrit :
Why were you surprised? Linux systems use the available RAM, surely you understand that?
I'm surprised because my system used the available RAM and then it even began to swap.
Of course there is the possibility that you have discovered a bug
Minimal CentOS 7 installation with BIND, Apache, MySQL, Postfix and Dovecot, regularly updated.
Hence my post. Wondering if other CentOS users experienced something similar.
Every system that runs continuously for more that a few days will have some pages that were used once when some long-running process started and were never referenced again. Those pages will eventually migrate out to swap, and that's the best place for them. Right now, I see that this system has been up for 16 days and has ~270MB of swap used. I typically see ~500MB of swap used when the system has been running a while longer.
Le 09/09/2017 à 15:14, Robert Nichols a écrit :
Every system that runs continuously for more that a few days will have some pages that were used once when some long-running process started and were never referenced again. Those pages will eventually migrate out to swap, and that's the best place for them. Right now, I see that this system has been up for 16 days and has ~270MB of swap used. I typically see ~500MB of swap used when the system has been running a while longer.
So, in other words, there's no need to worry if a little swap is used when the system's been running non-stop for a couple months?
Niki
Nicolas Kovacs wrote:
Le 09/09/2017 à 15:14, Robert Nichols a écrit :
Every system that runs continuously for more that a few days will have some pages that were used once when some long-running process started and were never referenced again. Those pages will eventually migrate out to swap, and that's the best place for them. Right now, I see that this system has been up for 16 days and has ~270MB of swap used. I typically see ~500MB of swap used when the system has been running a while longer.
So, in other words, there's no need to worry if a little swap is used when the system's been running non-stop for a couple months?
It´s nothing unusual and a good thing when it means that stuff not needed in memory is swapped out.
What is the advantage of emptying the cache supposed to be? I´ve had servers with the uptime-counter flowing over after years of uptime and never flushed the cache.
Le 09/09/2017 à 18:11, hw a écrit :
It´s nothing unusual and a good thing when it means that stuff not needed in memory is swapped out.
What is the advantage of emptying the cache supposed to be? I´ve had servers with the uptime-counter flowing over after years of uptime and never flushed the cache.
OK. Thanks very much for the clarification.
Cheers,
Niki Kovacs
On 2017-09-09, Nicolas Kovacs info@microlinux.fr wrote:
So, in other words, there's no need to worry if a little swap is used when the system's been running non-stop for a couple months?
As long as your system isn't thrashing swap it's totally fine. From what you've written it doesn't sound like you're thrashing.
--keith
On 09/09/2017 07:06 PM, Keith Keller wrote:
As long as your system isn't thrashing swap it's totally fine. From what you've written it doesn't sound like you're thrashing.
I should have mentioned earlier: Run "vmstat 1" and watch the "si" and "so" columns to watch paging activity.
On 09/09/2017 04:43 AM, Nicolas Kovacs wrote:
I read up a bit on RAM consumption, and now I wonder if flushing the memory cache regularly is a good idea.
Typically, no. Whatever pages of memory the system has swapped out are pages that the kernel's counters indicate are less often used than the pages that are in RAM.
The presence of pages in swap isn't necessarily bad. If, on the other hand, you were seeing pages actively swapped in and out of swap, that might indicate that the system needs more RAM than it has.
You can tune how conservative the system is about swapping memory in exchange for file cache by setting the "vm.swappiness" system parameter.