Psql Timeout connecting a new connection from collection pool

Hello, I used to get this error like a couple of times a day, which would crash my whole server. Today, it's been happening way more often. As soon as I start my server, my CPU usage goes too 100% and after a few mins, my servers crashes with the same error My chat app has like 1.5k users. Is there anyway to troubleshoot why this is happening?
5 Replies
CatNoir
CatNoirOP2w ago
No description
CatNoir
CatNoirOP2w ago
Could it be because I'm fetching A LOT of date like 1.5k times whenever a user connects? I see that I could use PGBouncer to fix this problem. Is it as simple as setting it to true in the params and that's all?
Yetzederixx
Yetzederixx2w ago
I'd imagine this can't help things out any. I know some chat apps seem to load like the last N messages and essentially enable "infinite scrolling" (aka paging) to get stuff in smaller chunks as the user scrolls
CatNoir
CatNoirOP2w ago
yea i already have that, it was caused by initial authenticated event, when the server sends hundrads of users and servers to 1.5k members. i need to maybe only load server members if the user clicks on the server for now, ive added PGBouncer which appears to have fixed the issue
Yetzederixx
Yetzederixx2w ago
You may need to setup some kind of message broker, or something, to broadcast like that in a way that's respectful to your database heh, glad bouncer worked though.
Want results from more Discord servers?
Add your server