supabase / supavisor

A cloud-native, multi-tenant Postgres connection pooler.
https://supabase.github.io/supavisor/
Apache License 2.0
1.76k stars 57 forks source link

Documentation is not clear on exactly how pooling settings work #228

Open jakeleventhal opened 10 months ago

jakeleventhal commented 10 months ago

Improve documentation

Link

https://supabase.com/blog/supavisor-postgres-connection-pooler

Describe the problem

If an application running on Supabase with Supavisor ONLY uses serverless functions, it will have N max clients.

It isn't clear exactly how exactly each of the N max clients are taken/made available upon each action in an application.

In session mode, will a single serverless function use up 1/N clients for the entirety of its lifetime? In other words, does it use a single connection once it is invoked until it goes back to a cold state (but does not require connecting more than once for multiple queries in the same function invocation, or even for subsequent invocations)?

In transaction mode, does that mean that you effectively have a budget of N concurrent database queries, regardless of how many functions are active/invoked at any given moment? For instance, assume a serverless function that makes a single DB query then sleeps for 10m. If I invoke this function N times in parallel, does that imply that the budget of max clients is:

  1. At time of all functions making DB query → 0/N
  2. The moment all functions finish the query → N/N
  3. The entire duration of the 10m function → N/N If I then decide to invoke that same function N more times while the initial invocations are all sleeping for 10m, I could do so since the connection to the DB is broken the moment the query completes?

How exactly this works isn't documented clearly.

Describe the improvement

Provide more clear explanation for how each mode works for Supavisor.

J0 commented 5 months ago

Hey @jakeleventhal,

Not sure if you managed to find an answer to the query but this guide may help clear things up: https://github.com/orgs/supabase/discussions/21566

Joel