|
2 | 2 | title: Resources Requirements |
3 | 3 | --- |
4 | 4 |
|
| 5 | +import { Callout } from "@hive/design-system/hive-components/callout"; |
| 6 | + |
| 7 | +<Callout> |
| 8 | + Before sizing your deployment, read [Concurrency & |
| 9 | + Scaling](/docs/gateway/concurrency-and-scaling) first. The CPU and memory |
| 10 | + numbers below depend directly on how many workers you run - understanding |
| 11 | + forking and its memory implications will make this guide much more actionable. |
| 12 | +</Callout> |
| 13 | + |
5 | 14 | Defining the right amount of resources for your GraphQL gateway is crucial for maintaining |
6 | 15 | performance and reliability. This guide will help you understand how to allocate resources |
7 | 16 | effectively. |
@@ -31,11 +40,13 @@ Set `NODE_ENV` to `production` to ensure your gateway runs in production mode. T |
31 | 40 | enables [parallelism optimizations](https://nodejs.org/api/cluster.html) that can enhance |
32 | 41 | performance. |
33 | 42 |
|
34 | | -By default, the gateway uses the available parallelism (number of CPUs, based on NodeJS's |
35 | | -`os.availableParallelism`) to determine the number of workers to spawn. |
| 43 | +By default, the gateway runs as a single process with no forking. You can set the `FORK` environment |
| 44 | +variable to specify the number of workers to spawn. For example, to spawn 4 workers, set `FORK=4`. |
| 45 | +Each worker is an independent Node.js process with its own memory heap, so your total memory |
| 46 | +requirement scales linearly with the fork count. |
36 | 47 |
|
37 | | -You can set the `FORK` environment variable to specify the number of workers you want to spawn. For |
38 | | -example, to spawn 12 workers, set `FORK=12`. |
| 48 | +See [Concurrency & Scaling](/docs/gateway/concurrency-and-scaling) for a full explanation of how |
| 49 | +forking works, how to choose the right fork count, and how to plan memory accordingly. |
39 | 50 |
|
40 | 51 | Consider unsetting the `DEBUG` env variable if you don't need debug logs. This can have significant |
41 | 52 | impact on CPU usage. |
0 commit comments