D
D
Dmitry2019-07-23 12:12:32
MySQL
Dmitry, 2019-07-23 12:12:32

Is it correct to keep a database connection open or open on every request in Node.js?

Good day, I have a lamer question. When writing a Node.js application using a mysql database, I connect to the database and use one connection for user requests.
Tell me, please, knowledgeable people, is it more correct to keep the connection or open / close it every time a request is made from the client?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail, 2019-07-23
@tixxxxon

Create a pool once (when the application starts). With each request, pull the connection from the pool

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question