Очистить / очистить кэш-память [дубликат]

Этот вопрос уже Здесь есть ответ:

У меня есть небольшой VPS с 6 ГБ ОЗУ, на котором размещено несколько веб-сайтов.

Недавно я заметил, что размер моей кэшированной памяти довольно велик - см. Ниже:

    Cpu(s):  0.1%us,  0.1%sy,  0.0%ni, 99.1%id,  0.0%wa,  0.2%hi,  0.4%si,  0.0%st
    Mem:   6113256k total,  5949620k used,   163636k free,   398584k buffers
    Swap:  1048564k total,      104k used,  1048460k free,  3586468k cached

После исследования, есть ли какой-либо способ сбросить или очистить это, я наткнулся на команду, которая:

    sync; echo 3 > /proc/sys/vm/drop_caches

Я читал, что это может будет полезно добавить это в хрон-задачу / задание. Рекомендуется ли этот метод или это может привести к потенциальным проблемам?

Единственное, что меня беспокоит, это то, что я использую одну установку Magento на Memcached - может ли это иметь какие-либо негативные последствия для нее?

Я, конечно, не профессионал, поэтому я был бы очень признателен за совет эксперта.

PS: Мой VPS работает на CentOS 5 x64, и у меня установлен WHM + NGINX.

5
задан 7 October 2012 в 16:14
3 ответа

Dropping your caches will likely impact your server's performance as it has to reread frequently accessed data back into the caches after every cache drop.

There is no real reason to drop your caches. To the Linux kernel memory being used for cache is essentially free and will be passed on to applications whenever they need it. Take a look at this website for more information.

Regarding the data stored in memcached - this safe from the effects of dropping the page/dentries/inodes caches.

7
ответ дан 3 December 2019 в 01:02

As said, there is little point in dropping caches unless you have a very compelling reason to do so. If you are not seeing any performance problem, leave it as it is.

If you are of the curious type, then you can tweak the parameter vm.vfs_cache_pressure. The default value is 100 which means that kernel will try to reclaim cache at a fair rate compared to reclaiming swap. Increasing the value would lead cached memory to be reclaimed faster and reducing it would lead to reclaiming swap faster, but remember this is just how kernel's aggressiveness to clear cache or swap is. Actual results vary from environment to environment.

In stead of echoing 3, you can also echo 1 or 2. If I remember correctly, echoing 1 will clear page cache and 2 will clear dentry and inode cache. 3 will clear pagecache, dentry and inode caches.

4
ответ дан 3 December 2019 в 01:02

There's no real harm to having that level of cached RAM. It's what Linux does.

Are you seeing any performance gain following dropping the caches? If not, then it's not worth scheduling it.

As a side, you can control what's in the cache with a little more granularity using the vmtouch utility.

2
ответ дан 3 December 2019 в 01:02

Теги

Похожие вопросы