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.

Read replicas are read-only. You cannot write to them.

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 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]

REST

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.

Before using any of the request data below, make the following replacements:

  • project-id: The project ID
  • primary-instance-name: The name of the primary (master) instance
  • primary-instance-region: The region of the primary (master) instance
  • replica-name: The name of the replica instance
  • machine-type: Enum string of the machine (tier) type. For example: "db-n1-standard-4"

HTTP method and URL:

POST https://www.googleapis.com/sql/v1beta4/projects/project-id/instances

Request JSON body:

{
  "masterInstanceName": "primary-instance-name",
  "project": "project-id",
  "name": "replica-name",
  "region": "primary-instance-region",
  "settings":
  {
    "tier": "machine-type",
    "settingsVersion": 0,
  }
}

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

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