AZ Lamps #16 — Azure PostgreSQL Read Replicas

Artem Mikulich
AZ Lamps by Artem Mikulich
2 min readApr 23, 2023

Azure provides three options to those seeking a PaaS SQL solution:

  • Azure SQL,
  • Azure Database for PostgreSQL,
  • Azure MySQL.

I am confident that Microsoft’s primary focus whoppingly goes to the Azure SQL since their baby — SQL Server, powers it. Nevertheless, they release relevant features for open-source solutions too.

Today I want to draw your attention to a new feature for PostgreSQLRead replicas. It allows configuring automatic data replication to a secondary server accessible for read-only operations. You may allocate the replica in the primary region and, for example, implement an academic CQRS — where writes and reads are executed by separate databases (see picture). However, this is not a must; you can offload the main server from just some read queries.

The second option is establishing a replica in another region to increase the system’s reliability. Then, in the case of a regional disaster, you will have a functional database with the latest (or very close to that) data. That’s a good starting point to recover!

CQRS powered by PostgreSQL Read Replicas

Note that replication is asynchronous, so the data replicates with a delay that depends on several factors. If you’re not moving back and forth terabytes of data, it will likely be seconds or even less. In any case, when you design the system, consider the potential lag.

--

--

Artem Mikulich
AZ Lamps by Artem Mikulich

I am a solution architect focused on Azure Cloud. My goal is to unlock business potential by eliminating technological barriers.