When your cache nodes try to use more memory than the instances have available to them, they will begin to swap. However, as both Memcached and Redis are in memory caches, swapping can defeat the purpose of using either cache and will slow down your application.

 

What Causes Swapping


Swapping in ElastiCache occurs when your node runs out of memory and tries to use some disk space as temporary memory. This can happen if you’re writing more than your cache can handle, or even as a result of ElastiCache taking a snapshot of your node. AWS suggests that you take action if your swapping exceeds 50mb.

 

 

What to Do about Swapping


If your cache nodes are swapping, there are two types of actions you can take. You can scale up, or you can set engine parameters that will lower the amount of memory your cache is allowed to use. If you choose to scale up, you can add nodes to your cluster, or use a larger cache node type. Otherwise, you will set Reserved Memory for Redis clusters, or the Connection Overhead parameter for Memcached.

 

 

RESOURCES