Answer a question

I currently have a problem with properly load balance open TCP sessions (created by the RoR application) to dynamically created Aurora Postgresql read-replicas.

The issue with this is when TCP connections are already established to one read-replica, another read-replica is created. After that traffic from the first replica will not be distributed evenly to second one, since TCP connections are already established with first replica.

Attached chart represents current infrastructure setup. Please note that between read-replicas (servers) and application (client) there is a load balancer, provided by the Aurora service, which is based on DNS round-robin.

enter image description here

I've tried pgbouncer, pgpool and multiple Ruby gems (makara, fresh_connection), but none of them were able to load balance nor eliminate long lived TCP connections..

I went through many articles and they helped investigate and confirm the issue; however none of them present a solution.

So... as you can see I've tried obey this problem from application and network perspective, unfortunately without luck. Has anyone had the same problem?

Answers

Finally I've figured this out and the fix had to be applied on application level in order to stop keeping long live TCP connections.

Particulary in Ruby I had to set idle_timeout and reaping_frequency parameters. However here you can find parameters for other programming languages.

Hope it help someone in future. Cheers!

Logo

PostgreSQL社区为您提供最前沿的新闻资讯和知识内容

更多推荐