Search code examples
postgresqlamazon-rdspgpool

pgpool for high availability of rds postgres


RDS Aurora for PostgreSQL Cluster has a writer and 2 reader nodes. When there is huge write activity and when reader node lags in catching up to those changes, aurora stops reader node(s) – catches up to the updates and starts the instance. This is done to avoid stale reads.

But this causes applications connecting to the readers fail while the readers are restarting, can I use pgpool or any other tool in this situation where it can monitor readers and when they are not up, forward the reads to writer? Want to avoid application failures, please advise on how best to approach this.


Solution

  • Sounds like you might be connecting straight to the reader node. You'll want to connect using reader endpoint for the cluster.

    If you select the cluster, under the "Connectivity and security" tab you will find a table with two "Endpoints". One is for the read only, and the other is for the write instance. Point your application to these and they will alias to the writer node, and load balance across the reader nodes. Of course I'm assuming your application is funneling the read only calls to one database connection and the read/write to another.

    Another route is to configure pgpool2 to load balance between your read/write and read only endpoints. That way your application doesn't have to keep track of which calls are read only etc.