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.
When exporting a RDB backup use the following guidance:
- Export during a period of low write-rate.
- If exporting during a period of high write-rate, temporarily lower
maxmemoryconfig to 50% of the instance capacity to provide sufficient overhead for a successful operation.
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:
- Version upgrade
- Scaling up/down
- Manual failover
- System maintenance
- Certificate Authority rotation for Redis instances that have in-transit encryption enabled
- Emergency failover
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.
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:
- Set a maintenance window for when maintenance updates can occur.
- Schedule maintenance windows for times of low instance traffic and sufficient memory overhead. For more information, see Impacts of maintenance updates.
- Turn on maintenance windows notifications to alert you of upcoming maintenance.
- Have retry logic with exponential backoff in place.
- For Standard Tier instances you can simulate a maintenance event by using manual failover to see how the failover caused by maintenance affects your application.
- For Basic Tier instances you can simulate the impact of a maintenance update by temporarily scaling the instance to a larger size. After you observe the impact you can scale back to the original size.
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
configuration for your instance to give yourself overhead in the case of high
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
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.
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:
- Setting a Cloud Monitoring alert for memory usage
- Setting a Cloud Monitoring alert for System Memory Usage Ratio