Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add clustering config to fork serve process for CPU core + load balancing #430

Merged
merged 3 commits into from
Aug 26, 2024

Conversation

aralroca
Copy link
Collaborator

Fixes #429

After this change it is by default enabled if it is production and it is Linux.


clustering

To improve the performance and reliability of your Brisa application, you can enable clustering through the clustering configuration property. When clustering is true, Brisa will fork the process for each CPU core and will load balance the requests.

The default value is true in production and when the operating system will load balance the requests correctly. Otherwise, the default value is false.

Warning

The load balancing is working fine only in Linux. On Windows and macOS, the operating system does not load balance HTTP connections as one would expect.

Example

//brisa.config.ts
import type { Configuration } from "brisa";

export default {
  clustering: true, // This enable clustering in prod and dev.
} satisfies Configuration;

To make it possible, Brisa uses node:cluster to handle the clustering. This Node API also works in Bun.

Caution

If you need to use a Custom Server, this configuration does not apply, and you need to handle the clustering yourself.

@aralroca aralroca merged commit 62a4dc4 into main Aug 26, 2024
0 of 3 checks passed
@aralroca aralroca deleted the aralroca/clustering branch August 26, 2024 23:12
@aralroca aralroca changed the title feat: add clustering config to fork server process for CPU core + load balancing feat: add clustering config to fork serve process for CPU core + load balancing Aug 26, 2024
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.

clustering config to fork serve process for CPU core + load balancing
1 participant