-
-
Notifications
You must be signed in to change notification settings - Fork 195
[RFC 0001] Connection Pooling #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
||
### 1. Decide on a PG Pooler | ||
|
||
- `pg_bouncer` - https://www.pgbouncer.org/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd vote for pgbouncer. Heroku(1) and DO(2) use it.
(1):https://www.digitalocean.com/community/tutorials/managed-databases-connection-pools-and-postgresql-benchmarking-using-pgbench (search for pgbouncer)
(2):https://devcenter.heroku.com/articles/best-practices-pgbouncer-configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also an AWS pgbouncer fork: https://github.com/awslabs/pgbouncer-rr-patch.
|
||
In Postgres, every connection is a process. Because of this, a lot of connections to the database can be very expensive on memory. | ||
|
||
When connecting to Postgres database from serverless functions, there is no connection pooling, and so the server needs to maintain hundreds/thousands of connections. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Transaction pooling and statement pooling(see pgbouncer types of pooling) might help there. The disadvantage of those is that they cannot use prepared statements for example, so we'd need to check for support on common client libs(too much work, maybe just document it).
Seems DO also recommends transaction pooling: https://assets.digitalocean.com/articles/managed_db_pools/connection_pool_blank.png
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed on this - when I look at the additional tooling around Postgres, pgbouncer seems to be the one supported most frequently (eg, pgmetrics
, various postgres operators
).
[drawbacks]: #drawbacks | ||
|
||
- Security | ||
- Not directly relevant to the "supabase" stack, so it's additional non-core support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add a dedicated GitHub discussion category for "External libraries" and mention it's low prio for us(plus reasoning).
Will merge this in for future reference. |
[RFC 0001] Connection Pooling
We would like to explore connection pooling on Supabase. This RFC is intended to decide:
Rendered