This parameter is dynamic and changing its value doesn’t require instance restart.įor example, the following Postgres log file message suggests that RDS is recovering a read replica by replaying archived WAL files: You can modify the value of this parameter using RDS Parameter Group. If the streaming replication halts for a longer time, you might see this message in the database log: Streaming replication has been terminated.īy default, RDS PostgreSQL sets wal_keep_segments to 32. So, the more WAL segments you keep on-instance, the faster the replication.Īfter the streaming replication stops, you should see the following error message in the database log: Streaming replication has stopped. In general, restoration from archive proceeds more slowly than streaming replication. If Read Replica does not find a WAL segment in the pg_wal location, Read Replica downloads the segment from the S3 bucket, then restores and applies it. Postgres archives any WAL segments exceeding this parameter to Amazon S3 buckets. ![]() In Postgres, the wal_keep_segments parameter specifies a maximum number of WAL log file segments kept in the pg_wal directory. In the following sections, I describe how to tune your Postgres instances to replicate RDS PostgreSQL instances hosted in the same Region optimally. The following diagram illustrates how RDS PostgreSQL performs replication between a source and replica in the same Region: If the process is for any reason delayed, replication lags. Data changes at the source instance stream to Read Replica using streaming replication. To create a read replica in the same AWS Region as the source instance, RDS PostgreSQL uses Postgres native streaming replication. Minimizing replication lag avoids both query outputs based on stale data and compromises to source instance health. You can confirm the data version by looking at the replication lag in Amazon CloudWatch metrics. General recommendationĪs an overall best practice, make sure that the read queries you run on Read Replicas use the latest version of the data as the source instance. ![]() The following steps show how to optimize DR strategy, read workload, and healthy source instance while minimizing replication lag. I recommend appropriate parameter values and metrics to monitor. ![]() I discuss the pros and cons of various RDS PostgreSQL replication options, including intra-Region, cross-Region, and logical replication. In this post, I provide some best practices for properly configuring Read Replicas. But you must configure Read Replicas properly and set appropriate parameter values to avoid replication lag. When you use an RDS PostgreSQL Read Replica instance, you both offload your read workload to a replica instance and reserve the source instance’s compute resources for write activities. You can configure Read Replicas within the same Region as the source or in a different Region. Amazon RDS for PostgreSQL enables you to easily configure replicas of your source PostgreSQL instance to clear your read load and to create disaster recovery (DR) resources.
0 Comments
Leave a Reply. |