Qiangning Hong wrote:
The manpage says: -k Lock down all paged memory. This is a somewhat dangerous option with large caches, so consult the README and memcached homepage for configuration suggestions.README says: Also, be warned that the -k (mlockall) option to memcached might be dangerous when using a large cache. Just make sure the memcached machines don't swap. memcached does non-blocking network I/O, but not disk. (it should never go to disk, or you've lost the whole point of it) Why locking pages in memory considered dangerous? It can avoid swapping, so that keep a good response time. Doesn't it a good feature?
It's likely considered dangerous due to the impact it can have on other applications running on the same system, or components of the OS. As you say, it is a good feature if used correctly. If you have, for instance, your application running on the same system and have a peak in user requests, it can lead to a situation where that application has memory needs and cannot get any more memory. Even though your cache could have a low response time, the overall user experience can be quite low.
I've recommended this flag to others in the past, and I'd just recommend start conservative (without creating too large a cache), monitor the environment, and tune from there.
Hope that helps, - Matt
