What is Memcached?
A client queries the front end cache, and if the query key is not found there, it is retrieved from the database. This usually leads to a key-value pair getting evicted from memcached.
The values corresponding to keys could be different sizes (a few bytes for Facebook status messages, to a few kilobytes for cover photos), so memcached uses slab based allocation. The RAM is divided into 1 MB sized pages and each page is divided into fixed size chunks (a chunk stores a value). Different classes of pages have different sized chunks.
The key-value store is organized as a hash table, using chaining for collision resolution. The eviction policy for the cache is LRU. The LRU policy is implemented by using a doubly linked list maintaining the LRU order.
Figure 1 : Memcached Architecture
Why Monitor Memcached?
In mission-critical environments, Memcached caching system provides capability to quickly access the data which will take long to be retrieved from database, and provides a real time experience to users and dependent applications. A slightest of issue with Memcached caching system can cause mission critical data not being available in the cache and application will have to reference the backend database. This can not only cause the deterioration in user experience but in certain use cases can cause the transaction to be timed out.
By closely monitoring the target Memcached caching system, administrators can be proactively alerted to issues in the overall performance and availability, identify serious issues, and plug the holes before any data loss occurs.