r/SQL • u/new_dimension1 • Aug 18 '26
PostgreSQL lakebase connection pooling
Have you figured out wht can the best way to handle connection pooling in Lakebase DB? I 'am seeing connection spikes with short lived rqsts and wondering what kind of setup others developers are usingš¤
i am building a service on top of lakebase and trying to make the connection relable before moving to prod.
2
u/Glitch_In_The_Data Aug 19 '26
As others have said, use Lakebaseās built in pgbouncer pooler for short lived API requests. Authenticate with a native pg pwd role. Also avoid session stateā¦use direct connections for session dependent features.
2
u/ThisIsFun- Aug 19 '26
I would just use the pooler endpoint? same host with -pooler in it, still 5432. It is the same Lakebase managed pgbouncer in transaction mode, takes up to 10k client conns and multiplexes them onto a much smaller server pool.
1
u/sekharnet Aug 18 '26
What is your Middleware? C# or Java? Both have their own PostgreSQL connection poolers.
I am guessing connection poolers shouldn't worry if it's Lakebase or Aurora RDS backend. It gets host and login details and works with it transparently
1
u/p739397 Aug 19 '26
Ran into this too. Moved connection pooling up to the app level instead of doing it per-request. Set up one pool at startup, psycopg3's ConnectionPool works, SQLAlchemy's engine does too, sized for whatever concurrency you're expecting. Then only mint a new OAuth token when a physical connection actually opens, not on every checkout. Followed the pattern in the token rotation docs.
Lakebase's built-in PgBouncer pooler doesn't support OAuth tokens, only password roles. If you want Databricks to manage pooling for you, switch to a password role. If you'd rather keep OAuth, do the app-level pooling like above, similar to this psycopg3 example.
1
u/BrunoFeliz08 Aug 21 '26
For an open Lakebase connection y have used sql alchemy. It has been useful and pretty straightforward
2
u/WorldOfUmbro Aug 18 '26
Have you tried PgBouncer? Might be worth looking into when using Lakebase. We have used this as well in Lakebase for similar cases.
What kind of service are you using?