This page provides instructions for enabling and managing read replicas.
Creating a Redis instance with read replicas
Console
Go to the Memorystore for Redis page in the Google Cloud console.
Click Create Instance.
Follow the instructions at Creating a Redis instance, but return to these instructions when selecting Tier.
Choose Standard tier.
Under the Configure read replicas dropdown, select your desired number of read replicas.
Return to the Creating a Redis instance instructions for additional guidance on other Memorystore configurations, or click the Create button.
gcloud
Enter the following command, replacing variables with appropriate values:
gcloud redis instances create instance-id --size=size --region=region-id --replica-count=count --read-replicas-mode=read-replicas-enabled --tier=standard
Where:
- count is a value from 1 to 5. This sets the number of read replicas.
Enabling read replicas on existing Redis instances
Console
Go to the Memorystore for Redis page in the Google Cloud console.
Click the ID of the instance.
Under the Configuration section, next to Read Replicas, click ENABLE.
(Optional) Specify a custom IP range
If your instance uses the direct peering connection mode, you can enter a specific CIDR range with a block size of at least
/28
, as long as it doesn't overlap with any other existing ranges. For example, you could enter10.100.0.0/28
.If your instance uses the private services access connection mode, you can choose an existing allocated range of size
/28
from the dropdown menu. For instructions on allocating an IP address range viewable from the dropdown menu, see Creating an IP allocation.
Click Enable Read Replicas.
gcloud
To enable read replicas for your instance, enter the following command, replacing variables with appropriate values.
gcloud beta redis instances update --read-replicas-mode=READ_REPLICAS_ENABLED --secondary-ip-range=SECONDARY_RANGE
Where:
- SECONDARY_RANGE is one of the following options:
auto
.auto
is supported for both networking connection modes.- If your instance uses the direct peering connection mode
you must provide a valid CIDR IP address range
of size
/28
. For example,--secondary-ip-range=10.100.0.0/28
. - If your instance uses the private services access connection mode
you must provide the name of an allocated range
of size
/28
. For example,--secondary-ip-range=my-secondary-range-memorystore
.
Scaling read replica enabled instances
Adding or removing replica nodes from your Redis instance
Console
- Go to the Memorystore for Redis page in the Google Cloud console.
Memorystore for Redis - Click the Instance ID of the instance to which you want to add/remove replica nodes.
- Click Edit.
- Under Configure read replicas, enter your desired number of replicas.
- Click Save.
gcloud
Enter the following command, replacing variables with appropriate values:
gcloud redis instances update instance-id --region=region-id --replica-count=count
Where:
- count is a value from 1 to 5. This sets the number of read replicas.
Scaling the size of Redis nodes
Console
- Go to the Memorystore for Redis page in the Google Cloud console.
Memorystore for Redis - Click the Instance ID of the instance you want to resize.
- Click Edit.
- Under Capacity, enter a new size in the field to update the instance's capacity.
- Click Save.
gcloud
Enter the following command, replacing variables with appropriate values:
gcloud redis instances update instance-id --region=region-id --size=size
Where:
- size is the size of each Redis node in your instance, including
the primary node. For example, if you have a read replica enabled instance
with six nodes (including the primary node) with
--size=10
, your total instance size is 60 GiB.
Connecting to your instance using the read endpoint
For instructions on using the read endpoint to connect to your instance, see Connecting to a Redis instance using the read endpoint.
Viewing read replica information for your instance
To find information about read replicas for your instance, run the following command replacing variables with appropriate values:
gcloud redis instances describe instance-id --region=region-id
In the metadata output from the previous command:
readEndpoint:
shows the read endpoint IP address.readEndpointPort
shows the read endpoint port number.readReplicasMode
shows if read replicas have been enabled.readReplicaCount
shows the number of replicas the instance has.nodes:
displays each replica node ID, and the region where each replica node is located.