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:
- there way create global object access values cluster?
- there way modify values of global object , value in cluster?
thank you!
so there can 2 approaches
- 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)
- 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
Post a Comment