node.js - Resource management for NodeJS -
in nodejs, there concept similar spring application container or jee application container resources can configured , shared among application components.
such resources are:
- database connection
- redis connection
- amqp connection ...
where these connections must/should open long time. it's bad practice open/close each http request.
in node.js, each module cached globally when require()
or import()
module same 1 every time.
so when data module consumes redis or db module , open connection, remain open until close it, , same connection may available other modules import data module.
some database/messaging modules provide connection pooling you. in fact should able find such modules on npmjs.com or node-modules.com , not have create own pooling solution common systems.
Comments
Post a Comment