0

I as using AuroraDB cluster with 2 readers and pgBouncer to maintain a connection pool.

My application is very read intensive and fires a lot of select queries.

the problem I am facing is my 2 read replicas are not getting used completely in parallel.

I can see the trends where all connections get moved to 1 replica where other replica is serving 0 connections and after some time the situation shift when 2nd replica serves all connections and 1st serves 0.

I investigated this and found that auroraDB cluster load balancing is done on by time slicing 1-second intervals.

My guess is when pgBouncer creates connection pool all connection are created within 1 second window and all connections end up on 1 read replica.

is there any way I can correct this?

Abhijeet Kale
  • 1,656
  • 1
  • 16
  • 34

1 Answers1

0

The DB Endpoint is a Route 53 DNS and load balancing is done basically via DNS round robin, each time you resolve the DNS. When you use pgBouncer, is it resolving the DNS once and trying to open connections to the resolved IP? If yes, then this is expected that all your connections are resolved to the same instance. You could fix this conceptually in multiple ways (I'm not too familiar with pgBouncer), but you basically need to somehow make the library resolve the DNS explicitly for each connection, or explicitly add all the instance endpoints to the configuration. The latter is not recommended if you plan on issuing writes using this Connection pool. You don't have any control over who stays as the writer, so you may inadvertently end up sending your writes to a replica.

AuroraDB cluster load balancing is done on by time slicing 1-second intervals I'm not too sure where you read that. Could you share some references?

The-Big-K
  • 2,672
  • 16
  • 35