node.js - Handling mysql db connection -


I am working on a high-performance real-time app with node.js and mysql as backend.

To increase the display, I have a separate node. JS process to update mysql bd underlaying. Update requests have been enqueued to guarantee execution (one required), respectively.

I am thinking of placing a permanent DB connection open in this process so that it will not be lost on opening every request.

Other DB-requests (updated or read) web-servers are given directly in parallel, from node-js example. These DB-Connections are definitely made / freed in each request.

Do you see some contradiction in this approach?

Update:

Important Additional Information I have originally selected this standalone process solution for the following reasons ...

The logic to be executed before each update is relatively complex and depends on the data-structure in the database. Many additional questions will be required before each update. This standalone process has complete data-structure in-memory and these check-ups can not be done very fast and with any DB access (performance boost).

Another option for your approach.

MySQL is notorious for closing connections based on timeouts, which are open for long periods of time. @Defimo is correct: using short-term connections from the pool is more likely to continue working for hundreds of hours with a long-established connection.

P>

I wonder: You say that sequential execution is necessary. Large-scale DBMS (including MySQL on a large server) is very capable of handling concurrent questions with multiple connections without corrupting the data. Your system will probably be more robust if you can work properly, what is mandatory about indexing your updates, if you can only index in SQL, or possibly in some transactions, then you will have more failure-resistant system If you insist that only one process updates. It is not easy to debug single purpose processes mentioned in system testing: they are notorious for failing hundreds of hours for all types of reasons. When they fail to produce, everyone is scrambling to restore them, so no one gives them time to troubleshoot them.


Comments