Search This Blog

Wednesday, June 20, 2012

Lock paged memory when using memcached by using memcached -k option

In case of memcached, paged memory should be locked for following reasons

1) If we reserve some paged memory for memcached then time would be saved in allocating memory for key/value pairs dynamically.
So memcached has memcached -k option to lock paged memory. But generally when you use this option you tend to get following error.

#memcached -u user -k &
warning: -k invalid, mlockall() failed: Cannot allocate memory

This occurs because by default llocked memory is only 64K. You can check this using
# ulimit -l

To change this, open /etc/security/limits.conf and then enter following lines at the end of file.

root   -     memlock   1048576

where root is the user who is going to run the memcached command from command line.

After that logout and login again and then check by using
#ulimit -l

No comments: