Your application’s read traffic doubled this quarter, the primary is at 65% CPU during peak, and the obvious move is a read replica. The PaaS dashboard has a “Add replica” button that finishes in five minutes. You also know how to set up streaming replication by hand. The first path is faster to provision. The second path is faster to recover when something goes wrong. Knowing which is which — and when each is the right call — saves you an outage.
What’s happening
The PaaS UI replica is a platform-orchestrated streaming replica. Under the hood it does what you’d do manually: pg_basebackup from the primary, configure primary_conninfo and primary_slot_name, start the replica in hot standby mode. Where it diverges is in observability and control:
- Where the WAL goes. The PaaS replica uses an internal replication slot the platform manages. You don’t see it in
pg_replication_slotsby name — it’s tagged with a platform-generated identifier. If the slot accumulates WAL because the replica is down, the primary’s pg_wal directory grows and you can’t easily reclaim space without going through the platform. - What you can change. PostgreSQL recovery parameters (
hot_standby_feedback,max_standby_streaming_delay,recovery_min_apply_delay) may be configurable via the dashboard or may be locked. On Jelastic-based PaaS, most are exposed in the UI; on some hyperscaler managed offerings, several are read-only. - How failover happens. PaaS UI replicas come with a “Promote” button that uses platform-managed health checks. The platform decides when the replica is “promotion-ready”; you don’t see the exact criteria. A hand-rolled replica with
pg_promote()lets you decide the moment. - What you observe. The PaaS UI exposes replication lag as a metric; you might or might not have access to
pg_stat_replicationdirectly depending on the role grants. A hand-rolled setup gives you fullpg_stat_replicationandpg_stat_wal_receiveraccess from day one. - What you sign up for. The PaaS replica’s failure modes are the platform’s responsibility; you open a support ticket. The hand-rolled replica’s failure modes are yours; you fix them on the call.
Both produce a functional read replica. The choice is about which side of the tradeoff matrix matches your operating model.
How to verify
For an existing PaaS UI replica, check what the platform actually configured:
-- On the primary
SELECT application_name, client_addr, state, sync_state,
pg_wal_lsn_diff(pg_current_wal_lsn(), replay_lsn) AS lag_bytes,
backend_start
FROM pg_stat_replication;
-- See the replication slot the platform created
SELECT slot_name, slot_type, active, restart_lsn,
pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn) AS retained_bytes
FROM pg_replication_slots;
On the replica:
-- Confirm hot standby and apply lag
SELECT pg_is_in_recovery();
SELECT now() - pg_last_xact_replay_timestamp() AS apply_lag;
SELECT pg_last_wal_receive_lsn(), pg_last_wal_replay_lsn();
If you’re considering rolling your own replica on top of a PaaS-provisioned primary (some platforms allow it, some block replication from outside the managed network), test reachability first:
# From the prospective replica host
psql -h primary.acme-prod.internal -U replicator -d postgres -c "SELECT 1;"
# Check that the primary's pg_hba.conf permits replication from your IP
psql -h primary.acme-prod.internal -U postgres -d postgres -c \
"SELECT * FROM pg_hba_file_rules WHERE type='hostssl' AND database='{replication}';"
If you can’t make a replication-grade connection from outside the PaaS network, the hand-rolled path requires moving the replica inside it — which usually means another PaaS environment, not a self-managed VM.
The fix
For Postgres, the hand-rolled streaming replica setup from a PaaS-hosted primary (assuming the PaaS allows external replication):
# 1. On primary: create a replication user and a slot
psql -h primary.acme-prod.internal -U postgres -c "
CREATE ROLE replicator WITH REPLICATION LOGIN PASSWORD 'CHANGE_ME';
SELECT pg_create_physical_replication_slot('replica_acme01');
"
# 2. On the replica host (AlmaLinux 9 with PostgreSQL 16 installed):
sudo systemctl stop postgresql-16
sudo -u postgres rm -rf /var/lib/pgsql/16/data/*
sudo -u postgres pg_basebackup \
--host=primary.acme-prod.internal \
--username=replicator \
--pgdata=/var/lib/pgsql/16/data \
--slot=replica_acme01 \
--write-recovery-conf \
--progress \
--verbose \
--checkpoint=fast \
--wal-method=stream
# 3. Confirm standby.signal is present and primary_conninfo is set
sudo -u postgres cat /var/lib/pgsql/16/data/standby.signal
sudo -u postgres cat /var/lib/pgsql/16/data/postgresql.auto.conf
# 4. Start the replica
sudo systemctl start postgresql-16
# 5. Verify replication is flowing
sudo -u postgres psql -c "SELECT pg_is_in_recovery();"
For MySQL, the equivalent hand-rolled streaming setup uses mysqldump for the base or Percona XtraBackup for online cloning:
# Option A: mysqldump for smaller databases (downtime-tolerant)
mysqldump -h primary.acme-prod.internal -u replicator -p \
--all-databases \
--master-data=2 \
--single-transaction \
--quick \
--triggers \
--routines \
--events \
| gzip > primary-base.sql.gz
# Option B: XtraBackup for large InnoDB workloads (online, preferred)
xtrabackup --backup \
--target-dir=/var/backups/xtrabackup \
--host=primary.acme-prod.internal \
--user=replicator \
--password=CHANGE_ME
xtrabackup --prepare --target-dir=/var/backups/xtrabackup
xtrabackup --copy-back --target-dir=/var/backups/xtrabackup
When to use which path:
- PaaS UI replica when: you want time-to-replica measured in minutes, you don’t need to peek inside the replication slot, the platform’s promotion logic is good enough, and you’re comfortable opening a ticket if it stops applying.
- Hand-rolled when: you need full
pg_stat_*access, you want the replica on a different cloud or region than the primary, you have specific recovery parameters that the platform locks, or you’re building a read tier that diverges from the platform’s defaults (delayed replica for human-error recovery, logical replica feeding a different schema, etc.).
The decision usually comes down to who owns the recovery runbook. If you do, build it; if the platform does, click the button.
Stack Harbor designs the right replica topology with you — when the PaaS UI is sufficient, we use it; when it isn’t, we add the hand-rolled tier on top — as part of Cloud PaaS. For a sit-down on which path your workload needs, start a scoping conversation.