node.js - How to set a global object when I use cluster? -


i'm working in app express , socket.io.

when started develop in app there not many information cluster. i'm trying implement cluster have problems this.

i think problems can resolve global object can access cluster.

so, questions two:

  1. there way create global object access values cluster?
  2. there way modify values of global object , value in cluster?

thank you!

so there can 2 approaches

  1. external storage : in cluster mode multiple processes act clusters , not recommend sharing global object , managing sessions keep these objects in sync between processes. recommend using redis or similar database (recommend redis quick , suites use case)
  2. global objects : yes, can create/modify objects copy of object in each process , have keep objects in sync. can use process.send() process , worker.send() workers master process. option see using libraries same : memored npm module or strongloops strong store cluster

i prefer keeping process independent , use common external storage, again should make decision based on use case.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -