Memcached and virtual memory

According to this thread (not very reliable, I know) memcached does not use disk, not even virtual memory .

My questions:

  • It's true?

  • If so, how does memcached guarantee that the memory it receives never overflows to disk?

+4
source share
2 answers

memcached avoids the exchange of two mechanisms:

  • Informing system administrators that machines should never switch. This allows administrators to probably not configure the swap space for the machine (it seems like a bad idea) or adjust the memory limits of running applications to ensure that nothing happens in swap. (Not only memcached , but all applications.)

  • The mlockall(2) system call can be used ( -k ) to ensure that all process memory is always locked in memory. This is mediated using the setrlimit(2) RLIMIT_MEMLOCK , so administrators will need to modify, for example. /etc/security/limits.conf so that the memcached user account blocks a lot more memory than usual. (Locked memory is indirect to prevent unreliable user accounts from starving the rest of the free memory system.)

Both of these steps are true if the point on the machine should be memcached and possibly quite a bit. This is often a fair assumption, as larger deployments will devote to several (or many) memcached machines.

+4
source

You are configuring memcached to use a fixed amount of memory. When this memory is filled with memcached, it simply deletes the old data to stay under the limit. It's simple.

+1
source

Source: https://habr.com/ru/post/1415665/


All Articles