P
Prisma2mo ago
Brilew

Hitting connection limits multiple times in a microservice environment

I run a bunch of AWS Fargate tasks and they all have their own prisma client connecting to the same database. Frequently, I come across the following error Timed out fetching a new connection from the connection pool. More info: http://pris.ly/d/connection-pool (Current connection pool timeout: 10, connection limit: 3) They're all relatively small instances, with 1vcpu 1gb ram each, and my metrics stay at around 30-40% usage so no need to upgrade them. However sometimes they come across multiple write operations that lead to the error above; I've read in other threads that just changing the connection limit isn't really ideal, and might just be sweeping the problem under the rug. Should I be doing anything specific to mitigate this?
1 Reply
Nurul
Nurul2mo ago
How many database connections does your database support? Assuming that you are using a Postgres database, can you run this SQL to check the number of database connections occupied by each application connected to your database?
SELECT application_name, usename, state, COUNT(*) AS connection_count
FROM pg_stat_activity
GROUP BY application_name, usename, state
ORDER BY connection_count DESC;
SELECT application_name, usename, state, COUNT(*) AS connection_count
FROM pg_stat_activity
GROUP BY application_name, usename, state
ORDER BY connection_count DESC;
Want results from more Discord servers?
Add your server