High Availability of databases is one of major Enterprise-grade features required by any Organization. It is important that databases are always accessible, minimizing downtime and maintaining business continuity. In the world of databases like PostgreSQL or Oracle or SQL Server, High Availability is achievable with the introduction of a Standby (or Replica), that continuously replicates data from its Primary (or Master). PostgreSQL, being one of the robust Open Source databases, supports multiple replication methods like Streaming and Logical Replication, that allow us to achieve high availability. In this article, we shall discuss the internals of Streaming Replication for setting up high availability in PostgreSQL along with its architecture. In the next article of this series, we shall see the detailed steps involved in setting up Streaming Replication for High Availability.
Please Note: To maintain the best quality in our articles, we avoid using any LLMs to create content as LLMs can hallucinate. Our high quality content may contain some manageable grammatical errors.
The most reliable and the HexaCluster recommended ways to achieve the same in PostgreSQL is to setup Streaming Replication. This replication technique is implemented by most robust tools like Patroni that supports Automatic failover. We will discuss about Patroni in another article.
Let us now understand what is Streaming Replication in PostgreSQL.
A quick Architecture Audit can save hours of troubleshooting later.
Try it Now!Let HexaRocket simplify it - migrate smarter, faster, and stress-free.
Contact us Today!HexaRocket performs end-to-end database migrations and replication seamlessly between Oracle, SQL Server, MySQL, MariaDB, and PostgreSQL.
Try Today!In order to achieve this, WAL records containing the changes made to the primary database are streamed to the standby database over a streaming replication protocol, ensuring that the standby is as up-to-date as possible.
The core principle of WAL is that the changes must be written to the WAL before they are written to the data files. This ensures that in the event of a crash, the system can replay WAL records to recover the database to a consistent state.
Now that we understood the important of WAL segments for the purpose of Streaming Replication, let us take a look at some of the background processes that enable Streaming Replication.
Following are some of the background processes you should know to understand how Streaming Replication works internally.
Please Note: In Streaming Replication, the writes involving DDL or DML can only be executed on the primary server, as the standby is always read-only.
hexacluster=# SELECT application_name,state FROM pg_stat_replication;
application_name | state
------------------+-----------
standby1 | startup
standby2 | catchup
standby3 | streaming
pg_basebackup | backup
standby4 | stopping
Following is the explanation of each of the above states.
Are you looking to migrate from Oracle to PostgreSQL ? We are here to support with a simple and seamless migration experience within 5 clicks using HexaRocket.
Request us for a demo on HexaRocket today: Schedule a demo.

Avi is the CEO and Co-founder of HexaCluster. Avi has a rich background in PostgreSQL, development, and machine learning. Before joining HexaCluster, he co-founded MigOps, a company dedicated to facilitating migrations to Open-Source databases like PostgreSQL. His journey in the PostgreSQL domain started at Dell followed by OpenSCG as a Database Architect and later joined Percona to start the PostgreSQL practice. Avi loves contributing to PostgreSQL, speaking at PostgreSQL conferences and writing PostgreSQL books.
Start your migration journey 🚀
start your migration journey with our expert team
Database & Application Migration Assessment Tool
End-to-End Database Migration & Modernization Tool
Database Code Object Conversion to PostgreSQL
MyBatis Mapper Conversion to PostgreSQL
Enterprise Data Replication & Live CDC
Oracle Compatibility Layer for PostgreSQL