Connection Pooling
To learn more about connection pooling generally, be sure to check out Prisma's Data Guide for a comprehensive overview on what connection pooling is, what it seeks to address, and how it works.
Accelerate provides built-in connection pooling by default. By using Accelerate, you get the benefits of connection pooling without having to configure anything. The efficient management of database connections allows the database to process more queries without exhausting the available database connections, making your application more scalable.
In some cases, however, it may be beneficial to further configure connection pooling in order to optimize the performance of your application.
This document focuses on the connection pooling features of Prisma Accelerate. For more information about the internal connection pool of Prisma ORM specifically, see our ORM connection pooling documentation.
Connection Pooling in Accelerate
By default, Accelerate has a connection limit of 10
. This means that Prisma Accelerate will open at most 10 database connections to your database per Prisma Schema used in Accelerate. For the Starter plan, this is also the maximum connection limit.
In most cases, this connection limit is sufficient. However, in high traffic or heavy compute environments, you may need to increase this value. If your project is on the Pro plan, the maximum connection limit is 100
. For Business plan projects the maximum is 1000
.
Configuring the connection pool size
When not using Prisma Accelerate, you can configure the connection pool of Prisma ORM via the connection string. When using Prisma Accelerate this feature is not available. Instead, you can configure the connection pool size in your Platform project via the Connection limit
setting on Accelerate setup.
Autoscaling
Autoscaling allows Accelerate to dynamically allocate resources based on your application's traffic. As consistent usage approaches the current connection limit, Accelerate will begin allocating new resources to handle the increased load. If traffic continues to rise, Accelerate will scale up further. Conversely, when traffic decreases, Accelerate will scale down accordingly.
Autoscaling is enabled when the Accelerate connection limit is set above the default value. This feature is not available on the Starter plan.
The maximum value of your Accelerate connection limit is based on your Prisma Data Platform plan.
Plan | Maximum Connection Limit |
---|---|
Starter | 10 |
Pro | 100 |
Business | 1000 |
Enterprise | Contact Us |
Configuring the connection pool timeout
The connection pool timeout is the maximum number of seconds that a query will block while waiting for a connection from Accelerate's internal connection pool. This occurs if the number of concurrent requests exceeds the connection limit, resulting in queueing of additional requests until a free connection becomes available. An exception is thrown if a free connection does not become available within the pool timeout. The connection pool timeout can be disabled by setting the value to 0.
Similar to the connection pool size, you may also configure the connection pool timeout via the database connection string. To adjust this value, you may add the pool_timeout
parameter to the database connection string.
For example:
postgresql://user:password@localhost:5432/db?connection_limit=10&pool_timeout=20
The default value for pool_timeout
is 10
seconds.
Configuring query limits
You can configure the minimum and maximum query response size, query duration, and transaction limits when using Prisma Accelerate from the Settings tab in your Accelerate-enabled project environment.
Query timeout limit
Accelerate has a default global timeout of 10s
for each query, configurable using the slider labeled Query duration, based on your subscription plan:
Plan | Starter | Pro | Business |
---|---|---|---|
Query timeout | Up to 10 seconds | Up to 20 seconds | Up to 60 seconds |
See the troubleshooting guide and our pricing page for more information.
While you can increase the query timeout, it’s recommended to inspect and optimize your database queries if they take longer than 10 seconds. This helps reduce stress on your underlying database, as long-running queries often indicate a need for optimization. Learn more in the troubleshooting guide.
Interactive transactions query timeout limit
Accelerate has a default global timeout of 15s
for each interactive transaction, configurable using the slider labeled Transaction duration, based on your subscription plan:
Plan | Starter | Pro | Business |
---|---|---|---|
Interactive transaction limit | Up to 15 seconds | Up to 30 seconds | Up to 90 seconds |
See the troubleshooting guide and our pricing page for more information.
While you can increase the interactive transaction timeout limit, it’s recommended to inspect and optimize your database transactions if they take longer than 15 seconds. Long-running transactions can negatively impact performance and often signal the need for optimization. Learn more in the troubleshooting guide and review the warning in the Interactive Transactions section in our documentation.
Response size limit
Accelerate has a default global response size limit of 5MB
, configurable using the slider labeled Response size, based on your subscription plan:
Plan | Starter | Pro | Business |
---|---|---|---|
Query size | Up to 5MB | Up to 10MB | Up to 20MB |
See the troubleshooting guide and our pricing page for more information.
While you can increase the query response size, it’s recommended to limit data retrieval to what you actually need. This improves database performance, reduces stress on your database, and makes your frontend applications more responsive. Queries exceeding 5 MB in size often indicate a need for optimization. Learn more in the troubleshooting guide.