Skip to content

Commit 5dd0bac

Browse files
authored
Open Link concurrency and scaling docs with resource requirements (#67)
1 parent 3357934 commit 5dd0bac

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

packages/documentation/content/docs/gateway/concurrency-and-scaling.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ That said, forking does work on Bun since it implements the Node.js `cluster` mo
142142
descriptors cannot be passed between workers, which limits TCP server load-balancing across
143143
processes to Linux only.
144144

145+
## Sizing Your Deployment
146+
147+
Once you have chosen a fork count, head over to
148+
[Resources Requirements](/docs/gateway/deployment/resources-requirements) to translate that decision
149+
into concrete CPU and memory allocations for your pods or VMs.
150+
145151
## Scaling Considerations for Multiple Instances
146152

147153
When running multiple gateway workers (via forking) or multiple gateway instances (e.g. multiple

packages/documentation/content/docs/gateway/deployment/resources-requirements.mdx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
title: Resources Requirements
33
---
44

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+
514
Defining the right amount of resources for your GraphQL gateway is crucial for maintaining
615
performance and reliability. This guide will help you understand how to allocate resources
716
effectively.
@@ -31,11 +40,13 @@ Set `NODE_ENV` to `production` to ensure your gateway runs in production mode. T
3140
enables [parallelism optimizations](https://nodejs.org/api/cluster.html) that can enhance
3241
performance.
3342

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.
3647

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.
3950

4051
Consider unsetting the `DEBUG` env variable if you don't need debug logs. This can have significant
4152
impact on CPU usage.

0 commit comments

Comments
 (0)