General best practices

This page provides guidance on optimally using Memorystore for Redis. This page also points out potential issues to avoid.

For a list of troubleshooting scenarios, see Troubleshooting.

RDB exporting

When exporting a RDB backup use the following guidance:

Resource-intensive operations

For Standard Tier Redis instances, the following operations use extra memory for the duration of the operation:

Version upgrade, scaling, and manual failover use extra memory (for Standard Tier instances) due to replication. These operations follow the replication process described in Standard Tier instance upgrade behavior.

Import and export operations require extra memory because of the forked Redis process and copy-on-write data management associated with these operations.

In order to mitigate the drawbacks of resource-intensive operations, you should:

  • Lower the maxmemory config to 80% of the instance capacity for the duration of the operation. This provides sufficient overhead for a successful operation.
  • Monitor the system memory usage ratio metric, and ensure that this metric is under 80% before running one of these operations.
  • Run these operations during periods of low instance traffic (such as overnight, or over the weekend, etc.).
  • Have retry logic with exponential backoff in place before running these operations.

Operations and scenarios that require a connection retry

The following operations and scenarios break the network connection between your network and the Redis instance:

These operations modify your instance, requiring a temporary connection break. You need to have retry logic with exponential backoff in place before running these operations so that your application automatically reconnects and continues to function normally.

Routine maintenance

Memorystore for Redis instances undergo maintenance periodically. For more details, see the Memorystore for Redis maintenance policy.

Implement the following best practices so you are prepared for routine maintenance:

Memory management

Memory management can be a challenge because of the well known memory fragmentation that occurs with open source Redis. We recommend that you lower the maxmemory configuration for your instance to give yourself overhead in the case of high memory pressure.

The best way to monitor the memory pressure on your Memorystore instance is by using the System Memory Usage Ratio metric. For more a detailed guide on how to manage memory for Memorystore for Redis, see Memory management best practices.

Basic Tier limitations

The Basic Tier is best used as an ephemeral cache, as it does not provide High Availability using replication.

For a full list of scenarios/operations that cause a cache flush for the Basic Tier, see Cache flush for Basic Tier.

Managing idle connections

Over time, you may see the number of connections to your Memorystore instance increase if connections are not being properly terminated. This can have negative performance implications, especially if you are using in-transit encryption, which imposes maximum connections limits based on your capacity tier. To mitigate this, we recommend utilizing the timeout Redis configuration parameter which allows you to set the number of seconds before idle client connections are automatically terminated.

Serverless VPC Access Connector required for some serverless environments

Some serverless environments require a Serverless VPC Access Connector in order to connect to Memorystore for Redis. Set up the Serverless VPC Access connector for your project if you want to connect using one of these environments.

Networking

We recommend that you use the private services access connection mode. Memorystore for Redis uses two connection modes: private services access and direct peering. The private services access connection mode makes IP range management more simple and allows you to use Shared VPC if you want.

Once you have created an instance, the connection mode cannot be changed.

For more details, see Networking.

Monitoring and alerts

We recommend using monitoring and alerts because they give you key signals on the memory usage of your Redis instance. They also give you insight into how efficiently your Redis instance responds to incoming cache requests.

You should set up the following default alerts: