Advanced level · Module 4: Replication, Availability and Recovery · Lesson 1 of 4
Streaming Replication
Copy changes continuously from a primary to standby servers and use replicas for reading.
In this lesson you will
- Set up a streaming replica
- Monitor replication lag and use read replicas appropriately
Key concepts
primary and standbywrite-ahead log streamingreplication lagread replica
The lesson
Streaming replication sends the primary's write-ahead log to standby servers, which apply it continuously. A standby can take over if the primary fails, and can serve read-only queries.
Replication lag is how far a standby is behind. Reports run on a replica may miss the latest changes; applications that need to read their own writes immediately should use the primary.
Replication protects against server failure, not mistakes: a DELETE on the primary is replicated too. Backups remain essential.
Step by step
- Configure a primary and a standby.
- Insert data on the primary and read it on the standby.
- Measure replication lag.
- Show that a mistaken DELETE is replicated.
Practice activity
Set up a streaming standby for the health database.
Expected result: The standby stays in sync, its lag is monitored and it answers read-only queries.
Check your understanding
-
Does replication replace backups?
Show answer
No; mistakes are replicated too.
-
What is replication lag?
Show answer
How far a standby is behind the primary.
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.