How to solve the problem that the linux server does not have enough memory
Linux server memory is not enough to solve, many novices are not very clear about this, in order to help you solve this problem, the following small series will explain in detail for everyone, there are people who need this to learn, I hope you can gain something.
As the server runs longer, its memory footprint increases. If the server memory is small, it is easy to have full memory, slow down the system, or even stuck. One solution is to increase physical memory, but this involves costs, downtime, opening the chassis, etc. Here's a treatment plan for you to follow. If the effect is good, you don't have to buy memory.
If you analyze the memory footprint of individual processes and add them together, it doesn't equal the total memory footprint. So why does the free -m instruction show that the remaining memory is so small? What does memory do?
The original operating system will choose part of the data cache to memory, free -m results
-/+ buffers/cache: The statistics behind are the cache data
The physical memory used by the cache plus the physical memory consumed by the process is the total physical memory.
In order to protect the service from being stuck due to high physical memory consumption, you can regularly schedule crontab to clear the cache data of the operating system every hour. The configuration is as follows. Every time 45 minutes on the hour, execute
echo 3 > /proc/sys/vm/drop_caches command to clear the operating system cache.
[root@localhost ~]# crontab -l
45 * * * * echo 3 > /proc/sys/vm/drop_caches
It turns out that clearing the cache does not slow down the system, but significantly speeds it up. Of course, my experimental scenario is the case where physical memory is already small, only 8 gigabytes, and the system access users are not large. There is no data to support the suitability of other systems.
Did reading the above help you? If you still want to have further understanding of related knowledge or read more related articles, please pay attention to the industry information channel, thank you for your support.