Creating Read Replicas

This page describes how to create a read replica for a Cloud SQL instance.

A read replica is a copy of the master that reflects changes to the master instance in almost real time. You create a replica to offload read requests or analytics traffic from the master. You can create multiple read replicas for a single master instance.

For more information about how replication works, see Requirements and Tips for Configuring Replication.

Console

  1. Go to the Cloud SQL Instances page in the Google Cloud Platform Console.

    Go to the Cloud SQL Instances page

  2. Find the instance you want to create a replica for, and open its more actions menu at the far right of its listing.

    Image of three-dot menu

  3. Select Create read replica.

    If you do not see that choice, the instance is a replica; you cannot create a replica of a replica.

  4. Click Create.

    You are returned to the instance page for the master.

gcloud

Create the replica:

gcloud sql instances create [REPLICA_NAME] --master-instance-name=[MASTER_INSTANCE_NAME]

cURL

Use the insert method of the instances resource to create the read replica. The region and databaseVersion properties must be the same as the master.

ACCESS_TOKEN="$(gcloud auth application-default print-access-token)"
curl --header "Authorization: Bearer ${ACCESS_TOKEN}" \
     --header 'Content-Type: application/json' \
     --data '{"masterInstanceName": "[MASTER_INSTANCE_NAME]", "name": "[REPLICA_NAME]",
              "region": "[MASTER_REGION]", "databaseVersion": "POSTGRES_9_6",
              "settings": {"tier":"[MACHINE_TYPE]"}}' \
     -X POST \
     https://www.googleapis.com/sql/v1beta4/projects/[PROJECT-ID]/instances

By default, the replica is created with the same number of CPUs and the same amount of memory as the master instance. You can increase these values for the replica, but you cannot decrease them.

What's next

Send feedback about...

Cloud SQL for PostgreSQL