summaryrefslogtreecommitdiffstats
path: root/health/guides/memcached/memcached_cache_memory_usage.md
blob: 2a14f01fc33a8263622e94e4239aa7e407401163 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
### Understand the alert

This alert indicates the percentage of used cached memory in your Memcached instance. High cache memory utilization can lead to evictions and performance degradation. The warning state is triggered when the cache memory utilization is between 70-80%, and the critical state is triggered when it's between 80-90%.

### What does cache memory utilization mean?

Cache memory utilization refers to the percentage of memory used by Memcached for caching data. A high cache memory utilization indicates that your Memcached instance is close to its maximum capacity, and it may start evicting data to accommodate new entries, which can negatively impact performance.

### Troubleshoot the alert

1. **Monitor cache usage and evictions**: Use the following command to display the current cache usage and evictions metrics:

   ```
   echo "stats" | nc localhost 11211
   ```
   Look for the `bytes` and `evictions` metrics in the output. High evictions indicate that your cache size is insufficient for the current workload, and you may need to increase it.

2. **Increase cache size**: To increase the cache size, edit the Memcached configuration file (usually `/etc/memcached.conf`) and update the value of the `-m` option. For example, to set the cache size to 2048 megabytes, update the configuration as follows:

   ```
   -m 2048
   ```
   Save the file and restart the Memcached service for the changes to take effect.

   ```
   sudo systemctl restart memcached
   ```

3. **Optimize your caching strategy**: Review your caching strategy to ensure that you are only caching necessary data and using appropriate expiration times. Making updates that reduce the amount of cached data can help prevent high cache memory usage.

4. **Consider cache sharding or partitioning**: If increasing the cache size or optimizing your caching strategy doesn't resolve the issue, you may need to consider cache sharding or partitioning. This approach involves using multiple Memcached instances, dividing the data across them, which can help distribute the load and reduce cache memory usage.

### Useful resources

1. [Memcached Official Documentation](https://memcached.org/)