Best practice for handling database connections in Next.js API routes with MySQL? #87277
Replies: 1 comment
-
|
Yeah, well depends, but mostly the right thing to do should be: If you have fluid compute on, an instance may be used to serve many requests, and each new incoming one creates a connection as you have it. Then you can execute the query against the pool, right? I think before fluid compute you'd create a connection, query, close and serve the data. And where to place it, well a That example creates a new mongo client in prod, you'd create a pool rather. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
I'm building a Next.js app with MySQL backend. I'm seeing connection pool exhaustion after ~50 API calls.
My questions:
Current approach feels inefficient and causing performance issues.
Additional information
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions