Skip to content

Vercel serverless functions causing database connection exhaustion #2639

@flacial

Description

@flacial

Description

Based on the analysis made by @JasirZaeem, we noticed we have been experiencing issues with our Vercel serverless function exhausting the database connections and causing the database to reach the maximum connections limit. This has resulted in errors and downtime for our application.

Upon further investigation, we have identified that the issue is caused by our Vercel serverless function making too many connections to the database in a short period of time. This is likely due to the high volume of requests being sent to the function, which is causing it to create a new connection for each request.

We believe that implementing a connection pooling solution, such as pgbouncer, could help resolve this issue. Connection pooling allows multiple connections to be grouped into a single "pool" and shared among multiple clients. This can help reduce the number of connections made to the database, as well as improve the performance and scalability of our application.

Steps to reproduce

  1. Send a high volume of requests to the Vercel serverless function
  2. Observe the database reaching the maximum connections limit and errors being thrown

Expected behavior

The Vercel serverless function should be able to handle the high volume of requests without exhausting the database connections and causing errors.

Actual behavior

The Vercel serverless function is causing the database to reach the maximum connections limit and throwing errors.

Solution

Implementing a connection pooling solution, such as pgbouncer, could help resolve this issue by reducing the number of connections made to the database and improving the performance and scalability of our application.

Resources

Metadata

Metadata

Assignees

Type

No type

Projects

Status

🦄 Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions