Prisma opening up connections for every repository query
Hey guys! My name is Rodrigo and im having some trouble with my repositories in an application taking longer times because of prisma:engine:connection.
From what I understand, Prisma has a pool of connection and it doenst need to open new connection for every query. But thats not whats Im seeing.
For better context, this application uses Node with Express and Prisma. I have a Adapter, Controller, Service and Repository architecture.
Prisma is instantiated only once, as documentation says, but i cant understand why, on a load test where I use locust to hit 250 users on 4 specific endpoints, i have "prisma:engine:connection" for every query. If there is anything more I can share so your guys better understand the problem, just ask for!
Here is a print screen of one endpoint call that took 5.7 seconds to complete from my Grafana + Tempo tracing. As shown in the picture, there are 4 prisma connection, but the entire endpoint had 7 connections with db, being all those connection almost 93% of the whole endpoint timing. This screenshot was taken when the application was overloaded by the load test.
As DB im using RDS with MySQL in a machine m7g.16xlarge, so it has very high specs. And the node server is hosted in 3 EC2 machines m6a.2xlarge. Im guessing infra aint the bottleneck. Do someone has some idea of what could be the problem?
Edit: Prisma v6.9.0 and Express v4.19.2

3 Replies
You're in no rush, so we'll let a dev step in. Enjoy your coffee, or drop into
#ask-ai if you get antsy for a second opinion!Hey!
Have you specified any
connection_limit in your connection string?
It seems that you are also running into an issue similar to this - https://github.com/prisma/prisma/issues/20088?GitHub
Long delays in repeated
prisma:engine:connection (reconnects exce...Bug description Our API runs Prisma on Fly.io connecting as a MySQL client to a database on Planetscale. This is a GraphQL API and we have a particular query that, without Redis caching, can have a...
@Nurul Hi Nurul!
Just like rodgc, I am experiencing a similar issue with slow queries. We have specified
connection_limit=30 and have two containers running for a total of 60 connections. In AWS RDS we constantly have 60~ connections (see image)
Is this normal/optimal? Or should connections be closed?
How does one properly set a good connection limit for containers/DB?
We are running a db.m6g.large DB along with 2 .5 vCPU 1GB ECS containers