anselan
DTDrizzle Team
•Created by anselan on 9/30/2024 in #help
Advice for pooling DB connections with serverless
but thank you, this really helped me to understand better what is going on!
43 replies
DTDrizzle Team
•Created by anselan on 9/30/2024 in #help
Advice for pooling DB connections with serverless
43 replies
DTDrizzle Team
•Created by anselan on 9/30/2024 in #help
Advice for pooling DB connections with serverless
43 replies
DTDrizzle Team
•Created by anselan on 9/30/2024 in #help
Advice for pooling DB connections with serverless
But I have just run a test now (set
max:1
for pooling) and didn't change anything on the Supabase side, and the "supavisor" connections have dropped significantly43 replies
DTDrizzle Team
•Created by anselan on 9/30/2024 in #help
Advice for pooling DB connections with serverless
oh, I get a 404 for that link!
43 replies
DTDrizzle Team
•Created by anselan on 9/30/2024 in #help
Advice for pooling DB connections with serverless
Right, so I am using Netlify, where roughly one function instance per "user", so pooling max:1 could actually be a good idea?
43 replies
DTDrizzle Team
•Created by anselan on 9/30/2024 in #help
Advice for pooling DB connections with serverless
Ah, so does it make sense to set the pg-node max to 1? Or is that a bad idea?
43 replies
DTDrizzle Team
•Created by anselan on 9/30/2024 in #help
Advice for pooling DB connections with serverless
And I'm still not 100% sure I'm understanding the optimal relation between pooling on the server ("client") side vs the Supavisor pooling.
For example, if I configure Drizzle via postgres-node to use Pooling, does that mean that no matter how many queries comprise a single "transaction" (which could roughly correspond to "a serverless function invocation"), only 1 "client connection" will be established to Supavisor (out of 200)?
43 replies
DTDrizzle Team
•Created by anselan on 9/30/2024 in #help
Advice for pooling DB connections with serverless
Very helpful, thanks. Where does this graphic come from?
43 replies
DTDrizzle Team
•Created by anselan on 9/30/2024 in #help
Advice for pooling DB connections with serverless
Is there even any benefit in doing this, as opposed to using a normal "client" connection, since Supabase is going to handle the pooling anyway?
43 replies
DTDrizzle Team
•Created by anselan on 9/30/2024 in #help
Advice for pooling DB connections with serverless
I guess the only part that is maybe less clear to me is... should I be using pooling on the "Drizzle" side of things as well? Because I am now using
43 replies
DTDrizzle Team
•Created by anselan on 9/30/2024 in #help
Advice for pooling DB connections with serverless
43 replies
DTDrizzle Team
•Created by anselan on 9/30/2024 in #help
Advice for pooling DB connections with serverless
Every Supabase project comes with a connection pooler for managing connections to your database. The pooler provides 2 important services: It manages connections for applications that connect and disconnect from the database frequently. For example, serverless functions and ORMs such as Prisma, Drizzle, and Kysely often make and drop connections to the database. If they connected directly each time, they would quickly exhaust your database server's memory. To connect to your database efficiently with such tools, you need a pooler.
43 replies
DTDrizzle Team
•Created by anselan on 9/30/2024 in #help
Advice for pooling DB connections with serverless
From the Supabase docs (Drizzle is mentioned specifically):
43 replies
DTDrizzle Team
•Created by anselan on 9/30/2024 in #help
Advice for pooling DB connections with serverless
Hmmm I might have solved my own problem 🙂 Supabase provides a Postgres DB but with their own automatic "connection pooler" in front of the database. Perfect for serverless setup like this. Each function invocation connects with its "own" client connection, but Supabase proxies the connection and re-uses connections to the actual database behind it. So far, seems to help a lot!
43 replies