Skip to content

Commit

Permalink
docs: add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aralroca committed Aug 26, 2024
1 parent 3effca1 commit dee70b3
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
1 change: 0 additions & 1 deletion packages/brisa/src/cli/serve/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ function handleError(errorName: string) {
],
stack: e.stack,
});
// throw e; // To display the error message, the stack trace and exit the process
};
}

Expand Down
4 changes: 4 additions & 0 deletions packages/docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ export default defineConfig({
text: 'Static pages',
link: '/building-your-application/configuring/static-pages',
},
{
text: 'Clustering',
link: '/building-your-application/configuring/clustering',
},
{
text: 'Content Security Policy',
link: '/building-your-application/configuring/content-security-policy',
Expand Down
35 changes: 35 additions & 0 deletions packages/docs/building-your-application/configuring/clustering.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
description: Learn how to cluster your Brisa application to improve performance and reliability.
---

# `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

:::tabs key:language
==TypeScript

```ts
//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`](https://nodejs.org/api/cluster.html) to handle the clustering. This Node API also works in Bun.

> [!CAUTION]
>
> If you need to use a [Custom Server](/building-your-application/configuring/custom-server), this configuration does not apply, and you need to handle the clustering yourself.
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,11 @@ By default (without custom server) is:
}
}
```

> [!WARNING]
>
> If you use a custom server you need to handle [clustering](/building-your-application/configuring/clustering) yourself.
> [!CAUTION]
>
> If you use a different runtime than Bun, like Node.js, you need to handle the WebSockets, HTTP/2, and other features yourself re-using the `serveOptions`.

0 comments on commit dee70b3

Please sign in to comment.