Allow multiple worker processes with cluster module #1705
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds the ability for the API to use multiple worker processes with Node.js's builtin
clustermodule.Historically, I've been opposed to adding this functionality, preferring that Pelias users manage parallelism on their own such as with Kubernetes or something else.
But there are enough use cases where that sort of orchestration isn't worth the complexity, and you want more than one CPU's worth of API requests.
This implementation is essentially lifted from the one in Placeholder, with mostly cosmetic changes only.
The biggest difference is the default. For backwards compatibility, without specifing the new
CPUSenvironment variable, the API will not use the cluster module and operate as a single process just like before.With the
CPUSvariable set to a number, that many worker processes will be launched, up to the number of CPUs detected on the machine.