Postgres 16 introduced support for logical replication from stand-by (replica) servers, a significant feature for CDC users. This post explains the difference between streaming and logical replication, the publish/subscribe model, and why offloading logical replication to replicas is beneficial for load distribution and peace of mind. It walks through setting up a test environment on Amazon RDS with a primary and read replica, configuring WAL level to logical, enabling hot_standby_feedback, creating a logical replication slot on the stand-by using pg_create_logical_replication_slot(), and verifying change events with pg_logical_slot_get_changes(). Trade-offs discussed include slightly higher latency and the inability to use Debezium's incremental snapshotting or heartbeat features on read-only replicas.

10m read timeFrom morling.dev
Post cover image

Sort: