Skip to content

Commit 572e4b0

Browse files
committed
RFC: connection pooling
1 parent 9c0fef4 commit 572e4b0

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

rfcs/0001-connection-pooling.md

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
feature: Connection Pooling
3+
start-date: 2021-02-04
4+
author: kiwicopple
5+
co-authors: steve-chavez, dragarcia
6+
related-issues: (will contain links to implementation PRs)
7+
---
8+
9+
# Summary
10+
[summary]: #summary
11+
12+
We would like to explore connection pooling on Supabase. This RFC is intended to decide:
13+
14+
- Whether we should provide a pooler
15+
- Which connection pooler we should use
16+
- Where in the stack it would be installed - i.e. if should bundle it with the Postgres build
17+
18+
19+
# Motivation
20+
[motivation]: #motivation
21+
22+
In Postgres, every connection is a process. Because of this, a lot of connections to the database can be very expensive on memory.
23+
24+
When connecting to Postgres database from serverless functions, there is no connection pooling, and so the server needs to maintain hundreds/thousands of connections.
25+
26+
27+
# Detailed design
28+
[design]: #detailed-design
29+
30+
This is still in the "Gather Feedback" stage. To start the discussion:
31+
32+
33+
### 1. Decide on a PG Pooler
34+
35+
- `pg_bouncer` - https://www.pgbouncer.org/
36+
- `PG Pool II` - https://www.pgpool.net/mediawiki/index.php/Main_Page
37+
- `odyssey` - https://github.com/yandex/odyssey
38+
- others?
39+
40+
### 2. Decide on configuration
41+
42+
Most poolers allow different configurations. We would need to decide on how we would configure the pooler by default
43+
44+
### 3. Decide if the user should be able re-configure the pooler
45+
46+
Should a user be able to change the configuration? If so, how would they do it?
47+
48+
49+
# Drawbacks
50+
[drawbacks]: #drawbacks
51+
52+
- Security
53+
- Not directly relevant to the "supabase" stack, so it's additional non-core support
54+
55+
# Alternatives
56+
[alternatives]: #alternatives
57+
58+
1. Since we already offer [PostgREST](https://github.com/postgrest/postgrest) and [postgres-meta](https://github.com/supabase/pg-api), this isn't entirely necessary for the Supabase stack. Bundling this is only beneficial for connecting external tools.
59+
2. We could hold back on this implementation until we move to a full Postgres Operator, which would include a pooler. It would be nice to have something for local development though.
60+
61+
62+
# Unresolved questions
63+
[unresolved]: #unresolved-questions
64+
65+
- Add any unresolved questions here
66+
67+
68+
# Future work
69+
[future]: #future-work
70+
71+
- Add any future work here

0 commit comments

Comments
 (0)