AWS:
Working with PostgreSQL read replicas in Amazon RDS - Amazon Relational Database Service
AZURE:
Read replicas - Azure Database for PostgreSQL - Single Server | Microsoft Docs
NOTE: Follows "Eventual Consistency" model! Data to be consistent can take more seconds to hours!
‼️ DONT do read replicas if your application or db-server is "write heavy"
- For most workloads read replicas offer near-real-time updates from the primary.
- However, with persistent heavy write-intensive primary workloads, the replication lag could continue to grow and may never be able to catch-up with the primary.
- This may also increase storage usage at the primary as the WAL files are not deleted until they are received at the replica.
- If this situation persists, deleting and recreating the read replica after the write-intensive workloads completes is the option to bring the replica back to a good state with respect to lag.
- Asynchronous read replicas are not suitable for such heavy write workloads.
- When evaluating read replicas for your application, monitor the lag on the replica for a full app work load cycle thru its peak and non-peak times to access the possible lag and the expected RTO/RPO at various points of the workload cycle.