redben
redben

Reputation: 5686

Creating resource in nodejs Cluster Master : good or bad?

All examples on node cluster api I have seen so far create express apps (for example) in the worker part.

Is there any reason why one should not create that express app in master and fork after initialization is done ?

The reason I'd like to do this is that at start up I might connect to the database, make some initial changes (say create mongodb collections, save boot status...etc) and having workers do that on their own might lead to duplicate actions on the database.

Upvotes: 1

Views: 133

Answers (1)

Ozzz
Ozzz

Reputation: 300

It may not be wise to put more on cluster master. Node cluster master shares the load to the other processes. If somehow V8 garbage collects on master, it will keep it from sharing the load during the GC. In such a case, there is no point having the cluster. Let master free and do whatever want you to do on workers.

Upvotes: 0

Related Questions