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

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -