Manage read replicas

This page provides instructions for enabling and managing read replicas.

Creating a Redis instance with read replicas

Console

  1. Go to the Memorystore for Redis page in the Google Cloud console.

    Memorystore for Redis

  2. Click Create Instance.

    Memorystore UI

  3. Follow the instructions at Creating a Redis instance, but return to these instructions when selecting Tier.

  4. Choose Standard tier.

  5. Under the Configure read replicas dropdown, select your desired number of read replicas.

  6. 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

  1. Go to the Memorystore for Redis page in the Google Cloud console.

    Memorystore for Redis

  2. Click the ID of the instance.

  3. Under the Configuration section, next to Read Replicas, click ENABLE.

  4. (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 enter 10.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.

  5. 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:

Scaling read replica enabled instances

Adding or removing replica nodes from your Redis instance

Console

  1. Go to the Memorystore for Redis page in the Google Cloud console.
    Memorystore for Redis
  2. Click the Instance ID of the instance to which you want to add/remove replica nodes.
  3. Click Edit.
  4. Under Configure read replicas, enter your desired number of replicas.
  5. 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

  1. Go to the Memorystore for Redis page in the Google Cloud console.
    Memorystore for Redis
  2. Click the Instance ID of the instance you want to resize.
  3. Click Edit.
  4. Under Capacity, enter a new size in the field to update the instance's capacity.
  5. 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.