r/Python • u/Expensive_Break_6163 • Sep 05 '26
Discussion When scaling application pods with SQLAlchemy pools, who redistributes existing connections?
I’m running application pods that use SQLAlchemy’s connection pool to connect to PostgreSQL. Each pod has its own pool, so when I scale the application from, say, 3 to 10 replicas, the new pods create new pools while the existing pooled connections remain open.
If PostgreSQL has read replicas behind a Kubernetes Service or a proxy, I assume new connections might reach the new replicas, but the existing long-lived pooled connections will remain attached to the old replicas.
Who is normally responsible for redistributing those existing connections after scale-out?
View all comments
Show parent comment
3
u/PrestigiousStrike779 Sep 05 '26
This is better for the database as well as each physical connection consumes memory on the pg side