Databases PostgreSQL flexible server field-manual-complete

PostgreSQL read replica

A PostgreSQL read replica is a second flexible server that follows a primary PostgreSQL server and accepts read-only traffic. Writes still go to the primary. The replica is useful when reporting, analytics, search indexing, or distant users are putting too much read pressure on the main database. Because replication is asynchronous, the replica can lag behind current writes. That lag matters. Learners should remember that a read replica is for read scale, regional reach, and recovery options, not for splitting ordinary writes across two active databases.

Aliases
PostgreSQL replica, PostgreSQL read-only replica, Azure PostgreSQL read replica, Read replica for PostgreSQL flexible server
Difficulty
fundamentals
CLI mappings
5
Last verified
2026-05-20T00:00:00Z

Microsoft Learn

A PostgreSQL read replica is a read-only Azure Database for PostgreSQL flexible server that asynchronously receives data from a primary server using PostgreSQL physical replication. Teams use replicas to offload read-heavy work, place data closer to users, and support disaster-recovery promotion.

Microsoft Learn: Read replicas in Azure Database for PostgreSQL flexible server2026-05-20T00:00:00Z

Technical context

In Azure architecture, a PostgreSQL read replica sits in the database replication and read-scale layer. Azure creates a separate flexible server and keeps it updated from the primary using PostgreSQL physical replication. The replica has its own endpoint, compute, storage, networking, monitoring, and control-plane lifecycle. It can be in the same region or another supported region, and it can be promoted when disaster recovery or role change is needed. It affects application connection routing, replica lag monitoring, firewall or private networking, parameter symmetry, billing, and major-version-upgrade planning.

Why it matters

Read replicas matter because many production databases are read-heavy long before they are write-heavy. Reporting dashboards, exports, BI tools, background jobs, search indexing, and customer portals can all compete with the primary workload. A replica lets architects move those reads away from the primary so order entry, checkout, dispatch, or user transactions stay responsive. Replicas also give teams another server that can be promoted during certain disaster-recovery scenarios, though promotion is an operator action and lag must be understood. The term matters operationally because it changes how applications choose endpoints, how teams monitor freshness, and how they think about cost versus performance.

Where you see it

Signals, screens, and Azure surfaces where this term usually becomes operational.

Signal 01

In the PostgreSQL flexible server Replication blade, the primary and replica servers appear with roles, endpoints, locations, and actions for creating or promoting replicas during operations review.

Signal 02

Azure CLI replica list output shows replica names, source server relationships, locations, states, and resource IDs used during monitoring or recovery planning conversations across regions.

Signal 03

Application configuration often contains a separate read connection string or routing rule that sends analytics, exports, or search indexing to the replica endpoint safely without touching writes.

When this becomes relevant

Specific situations where this term helps solve real Azure design, operations, migration, security, reliability, cost, or governance problems.

  • Move BI dashboards and scheduled reports away from the primary transactional PostgreSQL server.
  • Place read capacity in another region so distant users or services get lower-latency reads.
  • Create a promotion candidate for disaster recovery where asynchronous data loss risk is understood.
  • Protect write workloads from export, search indexing, and batch jobs that scan large tables.
  • Measure whether read scale is cheaper and safer than scaling the primary for mixed workloads.

Real-world case studies

Different enterprise-style examples that show the term being used to hit measurable objectives.

Case study 01

Streaming catalog reporting isolation

Scenario, objectives, solution, measured impact, and takeaway.

Scenario

A media streaming platform used PostgreSQL flexible server for catalog metadata, subscriptions, and playback entitlement checks. Analytics teams ran daytime catalog reports that competed with customer-facing reads and writes.

Business/Technical Objectives
  • Move reporting queries away from the primary database endpoint.
  • Keep entitlement and subscription writes responsive during business hours.
  • Allow analytics data to be slightly stale without affecting customer decisions.
  • Measure whether a replica was cheaper than scaling the primary.
Solution Using PostgreSQL read replica

The database team created a PostgreSQL read replica in the same region with a SKU sized for reporting concurrency. Application configuration kept subscription writes and entitlement checks on the primary, while Power BI extracts and catalog quality jobs used the replica endpoint. Operators monitored replica lag, primary CPU, IOPS, and reporting query duration for two weeks. Network rules matched the primary's private access pattern so analytics users did not gain a weaker path to data. Azure CLI scripts listed replicas, exported server IDs, and checked state before reporting windows. A cleanup policy required the replica owner and cost center to be reviewed every quarter.

Results & Business Impact
  • Primary CPU during reporting windows fell by 32 percent.
  • Playback entitlement p95 latency improved from 740 milliseconds to 310 milliseconds.
  • Analytics accepted a freshness target of less than five minutes of lag.
  • The replica cost 18 percent less than the proposed primary scale-up.
Key Takeaway for Glossary Readers

A read replica protects transactional workloads when read-heavy analytics can tolerate a clearly monitored freshness delay.

Case study 02

Travel marketplace regional reads

Scenario, objectives, solution, measured impact, and takeaway.

Scenario

A travel marketplace hosted its primary PostgreSQL flexible server in Western Europe. Asia-Pacific customer support tools frequently queried booking history and invoice records with noticeable latency.

Business/Technical Objectives
  • Reduce read latency for support agents far from the primary region.
  • Keep all booking changes on the primary to avoid split-write complexity.
  • Maintain data residency and access controls for replicated booking records.
  • Create a documented regional recovery option if the primary region failed.
Solution Using PostgreSQL read replica

The architecture team created a cross-region PostgreSQL read replica in Southeast Asia and routed only support-history reads to the new endpoint. Booking writes, cancellations, and payment updates stayed on the primary server. Private networking and database roles were reviewed separately for the replica, because it contained the same customer data. Operators configured lag alerts and trained support staff that very recent booking changes might take a short time to appear. The disaster-recovery runbook included manual promotion steps, expected DNS changes, and a reminder that promotion was not automatic. CLI evidence captured source server IDs, replica region, SKU, and state during quarterly drills.

Results & Business Impact
  • Support search latency for Asia-Pacific agents dropped by 55 percent.
  • No write paths were moved to the replica, avoiding application consistency changes.
  • Quarterly drills confirmed manual promotion steps in under 25 minutes.
  • Access review found and removed two roles that were unnecessary on the replica.
Key Takeaway for Glossary Readers

Read replicas can improve regional read experience and recovery posture when teams are honest about lag and manual promotion.

Case study 03

E-learning export workload separation

Scenario, objectives, solution, measured impact, and takeaway.

Scenario

An e-learning provider stored enrollment, quiz attempts, certificates, and transcript records in PostgreSQL flexible server. End-of-month institutional exports caused slowdowns for learners taking assessments.

Business/Technical Objectives
  • Move long-running export jobs away from learner assessment transactions.
  • Keep export data close enough to current for institutional reporting deadlines.
  • Avoid giving reporting workers elevated access on the primary server.
  • Retire the replica if query optimization solved the workload later.
Solution Using PostgreSQL read replica

The operations team created a PostgreSQL read replica dedicated to transcript exports and certificate verification reports. Export workers received a separate connection string and read-only database roles on the replica endpoint. The team monitored replica lag during assessment peaks and set exports to pause if lag exceeded the reporting freshness target. Query Store on the replica helped identify two inefficient transcript queries, which were rewritten before the replica was resized. Azure CLI listed replica state before each monthly run and exported cost tags for FinOps review. After three months, the team compared the replica cost with the learner latency improvement and kept the design.

Results & Business Impact
  • Assessment submission p95 latency improved by 43 percent during export weeks.
  • Transcript exports completed within the required four-hour reporting window.
  • Primary database read IOPS during month-end jobs dropped by 48 percent.
  • FinOps review confirmed the replica was cheaper than scaling the primary full time.
Key Takeaway for Glossary Readers

Read replicas are useful when batch readers can be isolated from live learners, buyers, patients, or operators who need the primary to stay fast.

Why use Azure CLI for this?

As an Azure engineer with ten years supporting data platforms, I use CLI for read replicas because replica state needs to be checked across servers and regions quickly. The portal shows relationships, but CLI lets me list replicas, create one with explicit location and SKU, capture IDs, and script evidence for disaster-recovery tests. During an incident, I do not want to click through blades to learn whether a replica is ready, where it lives, or which source server it follows. CLI also makes cleanup visible so temporary replicas do not become quiet monthly costs later during recovery drills and cost reviews.

CLI use cases

  • List all replicas for a primary server before maintenance, upgrade, or incident planning.
  • Create a read replica with an explicit name, location, zone, SKU, and storage decision.
  • Show replica server state, endpoint, SKU, and resource ID for routing or support evidence.
  • Promote a replica only after the approved disaster-recovery or planned switch process is ready.
  • Delete temporary reporting or migration replicas after validation to stop avoidable monthly cost.

Before you run CLI

  • Confirm tenant, subscription, source server, target replica name, resource group, region, zone, SKU, and storage size.
  • Check primary workload, replication lag tolerance, and whether heavy write activity could delay replica creation or catch-up.
  • Validate network mode, firewall rules, private DNS, and application routing before sending readers to the replica endpoint.
  • Treat create, promote, and delete commands as cost, routing, and recovery-impacting operations requiring approvals.
  • Use JSON output for replica IDs and states, and table output for quick relationship reviews.

What output tells you

  • Replica list output identifies which servers are replicas of the selected primary and where they are deployed.
  • Server state shows whether a replica is ready, updating, restarting, or unavailable for planned operations.
  • Location, zone, SKU, and storage fields explain cost, capacity, latency, and regional recovery behavior.
  • Source server IDs prove whether a replica follows the expected primary, especially across resource groups or subscriptions.
  • Promotion or delete output confirms that a control-plane operation changed the replica lifecycle and should update runbooks.

Mapped Azure CLI commands

PostgreSQL read replica CLI Commands

direct
az postgres flexible-server replica list --name <primary-server-name> --resource-group <resource-group> --output table
az postgres flexible-server replicadiscoverDatabases
az postgres flexible-server replica create --name <replica-server-name> --resource-group <resource-group> --source-server <primary-server-name> --location <region>
az postgres flexible-server replicaprovisionDatabases
az postgres flexible-server show --name <replica-server-name> --resource-group <resource-group> --query "{name:name,state:state,location:location,sku:sku,fullyQualifiedDomainName:fullyQualifiedDomainName}" --output json
az postgres flexible-serverdiscoverDatabases
az postgres flexible-server replica promote --name <replica-server-name> --resource-group <resource-group>
az postgres flexible-server replicaoperateDatabases
az postgres flexible-server delete --name <replica-server-name> --resource-group <resource-group>
az postgres flexible-serverremoveDatabases

Architecture context

As an Azure architect, I design PostgreSQL read replicas around workload separation and recovery intent. If the goal is reporting, applications need a clear read endpoint and a tolerance for stale data. If the goal is disaster recovery, the replica region, network configuration, parameter alignment, promotion process, and client failover plan all need rehearsal. Replicas are separate servers, so they need the same governance: private access or firewall rules, diagnostic settings, tags, backup expectations, and cost ownership. I also plan upgrade windows carefully because replicas can block or complicate major version upgrades. The best designs define which queries belong on replicas and which must always hit the primary.

Security

Security impact is direct because a read replica contains copied production data. It is read-only for workload writes, but it still exposes the same sensitive records to anyone who can connect and authenticate. Network rules, private access, firewall rules, PostgreSQL roles, TLS, diagnostic access, and secret handling must be reviewed separately for the replica. A common mistake is securing the primary carefully but leaving replica endpoints, DNS links, or support roles looser. If a replica is cross-region, data residency and compliance requirements also matter. Security evidence should prove that replica access, monitoring, and promotion permissions match the data classification exactly.

Cost

Cost impact is direct. Each PostgreSQL read replica is a separate flexible server billed for provisioned compute, storage, backup-related storage where applicable, networking, monitoring, and operational effort. The cost can be justified when it avoids scaling the primary only to serve reports or when it improves regional user experience and recovery posture. It can also surprise teams when replicas are created for temporary investigations and left running. FinOps review should compare replica cost with primary scale-up, query tuning, report scheduling, cache strategy, and the value of recovery readiness. Tags and owner fields are essential because replicas look like normal servers on the bill.

Reliability

Reliability impact is both helpful and limited. A read replica can reduce primary load and provide a server that may be promoted for disaster recovery, but it is not an automatic failover mechanism by itself. Replication is asynchronous, so lag can grow during heavy writes, network issues, or long-running transactions. If applications read from a lagging replica, users may see stale data. Reliable design includes replica lag monitoring, alerting, routing rules, promotion runbooks, and clarity about which workloads may tolerate stale reads. Teams should also understand that deleting a primary, performing major upgrades, or changing configurations can require replica-specific steps.

Performance

Performance impact is the main reason to use read replicas. By moving read-heavy queries away from the primary, teams can reduce CPU, IOPS, memory pressure, locks, and connection contention on the write server. Replica performance depends on its SKU, storage, network path, query mix, and replication lag. It is not a cure for inefficient reporting SQL; a bad query can still overload the replica. Cross-region replicas can improve read latency for distant users but add replication delay and operational complexity. Operators should measure primary load reduction, replica query latency, lag, and user freshness requirements before declaring the design successful overall.

Operations

Operators manage read replicas by creating replicas, monitoring lag, checking server state, validating networking, and controlling which applications use the replica endpoint. They inspect replica lists, replication roles, resource IDs, SKU, storage, private DNS or firewall settings, and diagnostic metrics. During incidents, they decide whether lag is acceptable, whether read traffic should be redirected, and whether promotion is justified. Operational runbooks should include create, monitor, promote, fail back, delete, and upgrade scenarios. Good operations also document which jobs use the replica so a performance problem on the reporting side does not accidentally become a production transaction incident later during ownership reviews.

Common mistakes

  • Sending user-facing reads to a replica without deciding how much stale data the application can tolerate.
  • Assuming a read replica is an automatic failover target that Azure will promote without operator action.
  • Securing the primary network carefully but forgetting separate firewall, DNS, and role checks on the replica.
  • Leaving temporary replicas running after reporting tests, migrations, or incident investigations are complete.
  • Starting a major version upgrade plan without checking whether replicas must be removed or recreated.