This page provides instructions for enabling and managing [read replicas](https://docs.cloud.google.com/memorystore/docs/redis/read-replicas).

## Create a Redis instance with read replicas

### Console

> [!NOTE]
> **Note:** Once you create and instance with read replicas, read replicas can't be disabled for that instance.

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

   [Memorystore for Redis](https://console.cloud.google.com/memorystore/redis/instances)
2. Click **Create Instance**.

   ![Memorystore UI](https://docs.cloud.google.com/static/memorystore/img/memorystore-ss1.png)
3. Follow the instructions at [Create a Redis instance on a VPC network](https://docs.cloud.google.com/memorystore/docs/redis/create-manage-instances.md.txt#create_a_redis_instance_on_a_vpc_network),
   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 [Create a Redis instance on a VPC network](https://docs.cloud.google.com/memorystore/docs/redis/create-manage-instances.md.txt#create_a_redis_instance_on_a_vpc_network)
   instructions for additional guidance on other Memorystore
   configurations, or click the **Create** button.

### gcloud

> [!NOTE]
> **Note:** Once you create and instance with read replicas, read replicas can't be disabled for that instance.

Enter the following command, replacing <var translate="no">variables</var> 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:

- <var translate="no">count</var> is a value from 1 to 5. This sets the number of read replicas.

## Enable read replicas on existing Redis instances

### Console

> [!IMPORTANT]
> **Important:**
> - Enabling [read replicas](https://docs.cloud.google.com/memorystore/docs/redis/read-replicas) on an existing Redis instance is an exclusive operation, meaning you cannot perform other [update operation](https://docs.cloud.google.com/sdk/gcloud/reference/redis/instances/update) instance modifications as a part of the same operation that enables read replicas.
> - After enabling read replicas, [scale the node count](https://docs.cloud.google.com/memorystore/docs/redis/manage-read-replicas.md.txt#add_or_remove_replica_nodes_from_your_redis_instance) to the number of read replicas that you want.
> - Before you enable read replicas on an existing Memorystore for Redis instance, we strongly recommend that you reduce the write traffic to the primary node. This way, the primary node can synchronize data to the replicas fully. If you don't reduce the write traffic, then you might not be able to enable the read replicas.

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

   [Memorystore for Redis](https://console.cloud.google.com/memorystore/redis/instances)
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](https://docs.cloud.google.com/memorystore/docs/redis/networking.md.txt#connection_modes),
     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](https://docs.cloud.google.com/memorystore/docs/redis/networking.md.txt#connection_modes),
     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](https://docs.cloud.google.com/vpc/docs/configure-private-services-access.md.txt#procedure).

5. Click **Enable Read Replicas**.

### gcloud

> [!IMPORTANT]
> **Important:** Enabling [read replicas](https://docs.cloud.google.com/memorystore/docs/redis/read-replicas) on an existing Redis instance is an exclusive operation, meaning you cannot perform other [update operation](https://docs.cloud.google.com/sdk/gcloud/reference/redis/instances/update) instance modifications as a part of the same operation that enables read replicas.   
>
> After enabling read replicas, [scale the node count](https://docs.cloud.google.com/memorystore/docs/redis/manage-read-replicas.md.txt#add_or_remove_replica_nodes_from_your_redis_instance) to the number of read replicas that you want.   
>
> Before you enable read replicas on an existing Memorystore for Redis instance, we strongly recommend that you reduce the write traffic to the primary node. This way, the primary node can synchronize data to the replicas fully. If you don't reduce the write traffic, then you might not be able to enable the read replicas.

To enable read replicas for your instance, enter the following command,
replacing <var translate="no">variables</var> with appropriate values.

```
gcloud redis instances update INSTANCE_ID --read-replicas-mode=READ_REPLICAS_ENABLED --secondary-ip-range=SECONDARY_RANGE
```

Where:

- <var translate="no">INSTANCE_ID</var> is the ID of the instance for which you're enabling read replicas.
- <var translate="no">SECONDARY_RANGE</var> is one of the following options:
  - `auto`. `auto` is supported for both networking connection modes.
  - If your instance uses the [direct peering connection mode](https://docs.cloud.google.com/memorystore/docs/redis/networking.md.txt#direct_peering) you must provide a [valid CIDR IP address range](https://docs.cloud.google.com/memorystore/docs/redis/networking.md.txt#supported_and_unsupported_networks) of size `/28`. For example, `--secondary-ip-range=10.100.0.0/28`.
  - If your instance uses the [private services access connection mode](https://docs.cloud.google.com/memorystore/docs/redis/networking.md.txt#private_services_access) you must provide the name of an [allocated range](https://docs.cloud.google.com/vpc/docs/configure-private-services-access.md.txt#procedure) of size `/28`. For example, `--secondary-ip-range=my-secondary-range-memorystore`.

## Scale read replica enabled instances

#### Add or remove replica nodes from your Redis instance

### Console

1. Go to the Memorystore for Redis page in the Google Cloud console.   
   [Memorystore for Redis](https://console.cloud.google.com/memorystore/redis/instances)
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 <var translate="no">variables</var> with appropriate
values:

```
gcloud redis instances update instance-id --region=region-id --replica-count=count
```

Where:

- <var translate="no">count</var> is a value from 1 to 5. This sets the number of read replicas.

#### Scale the size of Redis nodes

### Console

1. Go to the Memorystore for Redis page in the Google Cloud console.   
   [Memorystore for Redis](https://console.cloud.google.com/memorystore/redis/instances)
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 <var translate="no">variables</var> with appropriate
values:

```
gcloud redis instances update instance-id --region=region-id --size=size
```

Where:

- <var translate="no">size</var> 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.

## Connect to your instance using the read endpoint

For instructions on using the read endpoint to connect to your instance, see
[Connect to a Redis instance using the read endpoint](https://docs.cloud.google.com/memorystore/docs/redis/connect-redis-instance.md.txt#connect_to_a_redis_instance_using_the_read_endpoint).

## View read replica information for your instance

To find information about read replicas for your instance, run the following
command replacing <var translate="no">variables</var> 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.