Using SQL pool for multiple requests
I am running a Node.js express API and using the
mysql2
library to connect to a self-host mysql server (not possible to host on railway since it is using dolt, a git like sql server).
I have tried to use pooling with mysql2.createPool({...})
but this seems to open up a new sql connection each time instead of reusing an existing one. Eventually my sql server gets angry with so many connections open.
I have added a 60s timeout on the server end but am wondering if there is there a proper way to implement the pool connection such that railway will reuse across API requests? Or will I need to manually open and close each connection?
Thanks <a:party_railway:812486353853218816>3 Replies
Project ID:
9a03efbe-e496-4faa-b81c-64eb67a5f65d
You might find these helpful:
- Error connecting MySQL database with Express
- Trouble Connecting MySQL to express.js
- Connection pools and connections
⚠️ experimental feature
9a03efbe-e496-4faa-b81c-64eb67a5f65d