0

Does Google Cloud SQL read replicas guarantees consistency? And how long does it take to replicate from primary to read replicas typically? I can't find information on the above two questions.

william007
  • 117
  • 6

1 Answers1

0

Google Cloud SQL provides read replica eventual consistency. The time that it takes a replica to catch up to the master is called Replication lag.

How long is replication lag? That depends entirely on how busy the master and replicas are. You can determine this value by reading the Seconds_behind_Master metric (MySQL). See this link for PostgreSQL.

A good practice when updating the master is to set a flag and temporarily direct all reads to the master. This is typically handled by connection pooling logic that understands read-write masters and read-only slaves.

For more information see this document:

Managing replicas

John Hanley
  • 4,754
  • 1
  • 11
  • 21
  • "A good practice when updating the master is to set a flag and temporarily direct all reads to the master. This is typically handled by connection pooling logic that understands read-write masters and read-only slaves." - can you explain more on this? i.e., how does other application knows that the master is being written so that they are reading from master rather than slaves? – william007 Oct 22 '21 at 04:45
  • The software that manages connection pools typically has this feature. In order to properly support read-only replicas, you need software that knows which is which and only writes to the master. The same software can make decisions on replication lag and only read from the master for a short period of time. I have written articles about this on my website. – John Hanley Oct 22 '21 at 05:07