Max connection issues

I am running into max connection issues when I am using supabase within an application hosted in a serverless environment (vercel). I've done everything I can find by the docs, but if I have a spike of 300+ users on my app at once, I start to run into a lot of max connection errors. I am using trpc to help batch request and limit connections made. I create the postgres connection outside of drizzle, set max connections to 3, and pass the instance in. I am using transaction mode in supabase so it uses supavisor. I have prepared statements set to false. Does anyone have any advice that might be harder to come by? I am not as familiar with serverless environments and am about to pull the plug and move it over to a long-standing server to help my app scale. Went through this guide as well https://github.com/orgs/supabase/discussions/22305 Thanks!
GitHub
Preventing "Max client connections reached" Errors · supabase · Dis...
Based on comment by Chasers from the Supavisor Team. What causes "Max client connections reached" Errors The amount of connections the Supavisor pooler can support is determined by your d...
3 Replies
rphlmr ⚡
rphlmr ⚡2mo ago
Hey https://discord.com/channels/1043890932593987624/1290243511722971198 with Supabase and Supavisor, on base plan, you can have 200 simultaneous 'serverless invocation' max If you set 3 max connections in your client and a traffic spike creates 100 simultaneous instances, you will then consume 100 x 3 This is why I stay on a plain old long-running server (fly.io). I can control my auto-scale and keep it within boundaries. I don't know well Vercel and if you can set some limits. The other solution, if you are on pro plan (Supabase), is to open an issue. They helped us a lot to understand how all of this work
rphlmr ⚡
rphlmr ⚡2mo ago
GitHub
How to Monitor Postgres and Supavisor Connections · supabase · Disc...
This guide explains how connections impact your Supabase database's performance and how to optimize them for better resource utilization. Installing Supabase Grafana Supabase has an open-source...
Tanner Scadden
Tanner ScaddenOP2mo ago
Thank you! We figured out how to make it work for 2-3k users at the same time, but I am worried as by nature our app has huge traffic spikes at certain times. Was able to setup Grafana and by authenticating the jwt ourselves and saving the call to getUser from supabase I was able to reduce our median API response time by 60%, which is helping.
Want results from more Discord servers?
Add your server