Prisma Client and Serverless Functions: Connection Pool Sizing
0 reputation · 10 Feb 2025, 23:33 UTC
Prisma Client defaults to a connection pool configuration optimized for long-running server processes. In ephemeral serverless environments, where functions scale horizontally and terminate quickly, this default behavior can lead to rapid database connection exhaustion.
While the connection_limit parameter in the datasource URL allows for manual tuning, the optimal value remains dependent on the specific concurrency model of the serverless provider and the maximum connection capacity of the database engine.
There is currently no native mechanism within the client to dynamically scale the pool size based on the invocation lifecycle without relying on external middleware like PgBouncer or managed services like Prisma Accelerate.
- What is the recommended strategy for calculating the
connection_limitto balance request queuing against database connection limits in a high-concurrency serverless environment? - Is there a documented path for implementing a serverless-aware connection manager that adjusts pooling behavior per invocation?