Skip to content

Conversation

@orangejulius
Copy link
Member

@orangejulius orangejulius commented Oct 15, 2025

This adds the ability for the API to use multiple worker processes with Node.js's builtin cluster module.

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 CPUS environment variable, the API will not use the cluster module and operate as a single process just like before.

With the CPUS variable set to a number, that many worker processes will be launched, up to the number of CPUs detected on the machine.

This adds the ability for the API to use multiple worker processes with
Node.js's builtin [`cluster`](https://nodejs.org/api/cluster.html)
module.

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 `CPUS` environment variable, the API will
_not_ use the cluster module and operate as a single process just like
before.

_With_ the `CPUS` variable set to a number, that many worker processes
will be launched, up to the number of CPUs detected on the machine.
@orangejulius orangejulius merged commit 68163b1 into master Nov 11, 2025
6 checks passed
@orangejulius orangejulius deleted the cluster branch November 11, 2025 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants