Menu
Amazon ElastiCache
User Guide (API Version 2015-02-02)

Managing Reserved Memory (Redis)

Reserved memory is memory set aside for nondata use. When performing a backup or failover, Redis uses available memory to record write operations to your cluster while the cluster's data is being written to the .rdb file. If you don't have sufficient memory available for all the writes, the process fails. Following, you can find information on options for managing reserved memory for ElastiCache for Redis and how to apply those options.

How Much Reserved Memory Do You Need?

If you are running a version of Redis prior to 2.8.22, you need to reserve more memory for backups and failovers than if you are running Redis 2.8.22 or later. This requirement is due to the different ways that ElastiCache for Redis implements the backup process. The rule of thumb is to reserve half of a node type’s maxmemory value for Redis overhead for versions prior to 2.8.22, and one-fourth for Redis versions 2.8.22 and later. For more information, see Ensuring You Have Sufficient Memory to Create a Redis Snapshot and How Synchronization and Backup are Implemented.

Parameters to Manage Reserved Memory

The reserved-memory Parameter

Prior to March 16, 2017, all ElastiCache for Redis reserved memory management was done using the parameter reserved-memory. The default value of reserved-memory is 0. This default reserves no memory for Redis overhead and allows Redis to consume all of a node's memory with data. Changing reserved-memory so you have sufficient memory available for backups and failovers requires you to create a custom parameter group. In this custom parameter group, you set reserved-memory to a value appropriate for the Redis version running on your cluster and cluster’s node type.

The ElastiCache for Redis parameter reserved-memory is specific to ElastiCache for Redis and isn't part of the Redis distribution.

The following procedure shows how to use reserved-memory to manage the memory on your Redis cluster.

To reserve memory using reserved-memory

  1. Create a custom parameter group specifying the parameter group family matching the engine version you’re running—for example, specifying the redis2.8 parameter group family.

    Copy
    aws elasticache create-cache-parameter-group \ --cache-parameter-group-name redis28-m3xl \ --cache-parameter-group-family redis2.8
  2. Calculate how many bytes of memory you need to reserve for Redis overhead. You can find the value of maxmemory for your node type at Redis Node-Type Specific Parameters.

  3. Modify the custom parameter group so that the parameter reserved-memory is the number of bytes you calculated in the previous step. The following AWS CLI example assumes you’re running a version of Redis prior to 2.8.22 and need to reserve half of the node’s maxmemory.

    Copy
    aws elasticache modify-cache-parameter-group \ --cache-parameter-group-name redis28-m3xl \ --parameter-name-values “ParameterName=reserved-memory, ParameterValue=7130316800

    Note that you need a separate custom parameter group for each node type that you use, because each node type has a different maxmemory value. Thus, each node type needs a different value for reserved-memory.

  4. Apply the custom parameter group to your cluster.

    The following CLI example applies the redis28-m3xl parameter group to the cluster my-redis-cluster.

    Copy
    aws elasticache modify-cache-cluster \ --cache-cluster-id my-redis-cluster \ --cache-parameter-group-name redis28-m3xl \ --apply-immediately

    The following CLI example applies the redis28-m3xl parameter group to the replication group (in the console, the cluster) my-redis-repl-grp.

    Copy
    aws elasticache modify-replication-group \ --replication-group-id my-redis-repl-grp \ --cache-parameter-group-name redis28-m3xl \ --apply-immediately

For more information, see Modifying an ElastiCache Cluster or Modifying a Cluster with Replicas.

 

The reserved-memory-percent parameter

On March 16, 2017, Amazon ElastiCache introduced the parameter reserved-memory-percent and made it available on all versions of ElastiCache for Redis. The purpose of reserved-memory-percent is to simplify reserved memory management across all your clusters. It does so by enabling you to have a single parameter group for each parameter group family (such as redis2.8) to manage your clusters' reserved memory, regardless of node type. The default value for reserved-memory-percent is 25 (25 percent).

The ElastiCache for Redis parameter reserved-memory-percent, like reserved-memory, is specific to ElastiCache for Redis and isn't part of the Redis distribution.

To use reserved-memory-percent to manage the memory on your ElastiCache for Redis cluster, do one of the following:

  • If you are running Redis 2.8.22 or later, just assign the default parameter group to your cluster. The default 25 percent should be adequate. If not, you can follow the steps in the next bullet to change the value.

     

  • If you are running a version of Redis prior to 2.8.22, you likely will need to reserve more memory than reserved-memory-percent's default 25 percent. To do so, use the following procedure.

To reserve memory using reserved-memory-percent

  1. Create a custom parameter group specifying the parameter group family matching the engine version you’re running—for example, specifying the redis2.8 parameter group family. A custom parameter group is necessary because you cannot modify a default parameter group.

    Copy
    aws elasticache create-cache-parameter-group \ --cache-parameter-group-name redis28-50 \ --cache-parameter-group-family redis2.8

    Because reserved-memory-percent reserves memory as a percent of a node’s maxmemory, you don't need a custom parameter group for each node type.

  2. Modify the custom parameter group so that reserved-memory-percent is 50 (50 percent).

    Copy
    aws elasticache modify-cache-parameter-group \ --cache-parameter-group-name redis28-50 \ --parameter-name-values "ParameterName=reserved-memory-percent, ParameterValue=50"
  3. Use this custom parameter group for any Redis clusters running a version of Redis older than 2.8.22.

    The following CLI example applies the redis28 parameter group to the cluster my-redis-cluster.

    Copy
    aws elasticache modify-cache-cluster \ --cache-cluster-id my-redis-cluster \ --cache-parameter-group-name redis28-50 \ --apply-immediately

    The following CLI example applies the redis28-50 parameter group to the replication group (in the console, the cluster) my-redis-repl-grp.

    Copy
    aws elasticache modify-replication-group \ --replication-group-id my-redis-repl-grp \ --cache-parameter-group-name redis28-50 \ --apply-immediately

For more information, see Modifying an ElastiCache Cluster or Modifying a Cluster with Replicas.

Changing Between the reserved-memory and reserved-memory-percent Parameters

If you were a current ElastiCache customer on March 16, 2017, your default reserved memory management parameter is reserved-memory. If you became an ElastiCache customer after March 16, 2017, your default reserved memory management parameter is reserved-memory-percent. You can change your reserved memory management parameter if you want using either the AWS CLI or ElastiCache API.

The parameters reserved-memory and reserved-memory-percent are mutually exclusive. A parameter group will always have one but never both. You can change which parameter a parameter group uses for reserved memory management by modifying the parameter group. The parameter group must be a custom one, because you cannot modify default parameter groups.

The following CLI example modifies the custom parameter group redis32-cluster-on so that it uses reserved-memory-percent to manage reserved memory. Because the engine version is newer than 2.8.22, it sets the value of reserved-memory-percent to 25 (25 percent) even though that is the default. It does so because reserved-memory-percent must be assigned some value to convert the parameter group from reserved-memory to reserved-memory-percent.

Copy
aws elasticache modify-cache-parameter-group \ --cache-parameter-group-name redis32-cluster-on \ --parameter-name-values "ParameterName=reserved-memory-percent, ParameterValue=25"

The following CLI example modifies the custom parameter group redis32-m3xl so that it uses reserved-memory to manage reserved memory. Because the engine version is newer than 2.8.22, it sets the value to 3565158400 which is one-fourth of a cache.m3.xlarge’s maxmemory.

Copy
aws elasticache modify-cache-parameter-group \ --cache-parameter-group-name redis32-m3xl \ --parameter-name-values "ParameterName=reserved-memory, ParameterValue=3565158400"