1

We have a production server with 4GB of RAM running Debian with webserver and various other applications. Checking from the command line using htop, about 3.7-3.8GB of the RAM is used at any given time.

The server is not showing signs of slowness or unresponsiveness. Is it fine to run a server like this at near 100% RAM utilization, or can some problems arise in the future?

Output of free:

              total        used        free      shared  buff/cache   available
Mem:        3957164     3108136      189128       22348      659900      567960
Swap:       4108284      143104     3965180

Here's a screenshot of the htop output: HTOP (usually RAM usage is higher, the server was rebooted recently)

HTOP output

rhw555
  • 80
  • 7
  • 1
    Does that include the memory used for cache? You should edit your question to include the output of htop. If you're actually using 95% of your RAM that gives you less of a buffer for sudden demands and reduces the file caching you can do. If you're actually using 2GB and 1.8GB is used as a file cache, you're fine, as the cache can be dropped any time memory is needed. – Tim Oct 02 '19 at 19:57
  • https://serverfault.com/questions/449296/why-is-linux-reporting-free-memory-strangely – Tim Oct 02 '19 at 19:58
  • Thanks Tim, I added the htop screenshot – rhw555 Oct 02 '19 at 20:34
  • Please run "free" and edit your question to include the output - suggest as text rather than screenshot. – Tim Oct 02 '19 at 20:47
  • If a server in the future needs more then 4G it will start to swapping. This will cause lower performance. If you don't have enough swap memory OOM killer will start to killing processes to free memory and to keep a system up. – Damir Nemčanin Oct 02 '19 at 21:39
  • Added "free" to the original question. Thanks again, Tim. – rhw555 Oct 02 '19 at 22:37

1 Answers1

2

Approaching 0% available memory, the kernel will try increasingly drastic things to ensure some is available. Rapid paging out of RAM to storage can cause drastic slowdowns. The OOM killer reduces performance to zero when it kills processes. Still better than panicing and rebooting.

The key word is available memory. Linux will use any free memory it can for caches, which are automatically made available for allocation. Obligatory citation of the canonical FAQ: https://www.linuxatemyram.com/

htop there is reporting about 77% utilization and 1% page space use. Nice fully utilizing it, but the free output shows a few percent higher and its starting to swap. A couple GB more RAM, up to 6 or 8 GB maybe, would be a nice buffer. Especially if it is one your production boxes.

John Mahowald
  • 30,009
  • 1
  • 17
  • 32