Hi, I am relatively new to using Aiven and PostGreSQL as well. I created a Next JS web app for my university which uses Prisma to connect to Aiven. However, when the other students used it, I got this error in my Vercel log: “Too many database connections opened: FATAL: remaining connection slots are reserved for non-replication superuser connections”
I think it might be related to the 20 connection limit at Aiven free plan but I still want to be sure before I make any purchases. When this error happens I need to redeploy my app otherwise it does not get fixed.
Here is my database connection string parameters: defaultdb?sslmode=require&max-connections=15
And here is my prisma.tsx. I am only instantiating Prisma once in my app.
import { PrismaClient } from ‘@prisma/client’;
let prisma: PrismaClient;
if (process.env.NODE_ENV === “production”) {
prisma = new PrismaClient();
} else {
if (!global.prisma) {
global.prisma = new PrismaClient();
}
prisma = global.prisma;
}
export default prisma;
Thank you for the help. And sorry if this question might appear silly.