You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Updates the NGF scaling doc for new capabilities being added in 2.1. HorizontalPodAutoscaling and updating worker connections. Also added the updated API reference guide for these changes.
Finally, added some missing conditions in the compatibility doc.
Copy file name to clipboardExpand all lines: content/ngf/how-to/scaling.md
+45-15Lines changed: 45 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,36 +16,64 @@ It provides guidance on how to scale each plane effectively, and when you should
16
16
17
17
The data plane is the NGINX deployment that handles user traffic to backend applications. Every Gateway object created provisions its own NGINX deployment and configuration.
18
18
19
-
You have two options for scaling the data plane:
19
+
You have multiple options for scaling the data plane:
20
20
21
+
- Increasing the number of [worker connections](https://nginx.org/en/docs/ngx_core_module.html#worker_connections) for an existing deployment
21
22
- Increasing the number of replicas for an existing deployment
22
23
- Creating a new Gateway for a new data plane
23
24
24
-
#### When to increase replicas or create a new Gateway
25
+
#### When to increase worker connections, replicas, or create a new Gateway
25
26
26
-
Understanding when to increase replicas or create a new Gateway is key to managing traffic effectively.
27
+
Understanding when to increase worker connections, replicas, or create a new Gateway is key to managing traffic effectively.
27
28
28
-
Increasing data plane replicas is ideal when you need to handle more traffic without changing the configuration.
29
+
Increasing worker connections or replicas is ideal when you need to handle more traffic without changing the overall routing configuration. Setting the worker connections field allows a single NGINX data plane instance to handle more connections without needing to scale the replicas. However, scaling the replicas can be beneficial to reduce single points of failure.
29
30
30
-
For example, if you're routing traffic to `api.example.com` and notice an increase in load, you can scale the replicas from 1 to 5 to better distribute the traffic and reduce latency.
31
+
Scaling replicas can be done manually or automatically using a [Horizontal Pod Autoscaler](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/) (HPA).
31
32
32
-
All replicas will share the same configuration from the Gateway used to set up the data plane, simplifying configuration management.
33
+
To update worker connections (default: 1024), replicas, or enable autoscaling, you can edit the `NginxProxy` resource:
33
34
34
-
There are two ways to modify the number of replicas for an NGINX deployment:
First, at the time of installation you can modify the field `nginx.replicas` in the `values.yaml` or add the `--set nginx.replicas=` flag to the `helm install` command:
The NginxProxy resource in this example lives in the control plane namespace (default: `nginx-gateway`) and applies to the GatewayClass, but you can also define one per Gateway. See the [Data plane configuration]({{< ref "/ngf/how-to/data-plane-configuration.md" >}}) document for more information.
42
+
43
+
{{< /call-out >}}
44
+
45
+
- Worker connections is set using the `workerConnections` field:
46
+
47
+
```yaml
48
+
spec:
49
+
workerConnections: 4096
40
50
```
41
51
42
-
Secondly, you can update the `NginxProxy` resource while NGINX is running to modify the `kubernetes.deployment.replicas` field and scale the data plane deployment dynamically:
52
+
- Replicas are set using the `kubernetes.deployment.replicas` field:
- Autoscaling can be enabled using the `kubernetes.deployment.autoscaling` field. The default `replicas` value will be used until the Horizontal Pod Autoscaler is running.
62
+
63
+
```yaml
64
+
spec:
65
+
kubernetes:
66
+
deployment:
67
+
autoscaling:
68
+
enable: true
69
+
maxReplicas: 10
46
70
```
47
71
48
-
The alternate way to scale the data plane is by creating a new Gateway. This is beneficial when you need distinct configurations, isolation, or separate policies.
72
+
See the `NginxProxy` section of the [API reference]({{< ref "/ngf/reference/api.md" >}}) for the full specification.
73
+
74
+
All of these fields are also available at installation time by setting them in the [helm values](https://github.com/nginx/nginx-gateway-fabric/blob/main/charts/nginx-gateway-fabric/values.yaml).
75
+
76
+
An alternate way to scale the data plane is by creating a new Gateway. This is beneficial when you need distinct configurations, isolation, or separate policies.
49
77
50
78
For example, if you're routing traffic to a new domain `admin.example.com` and require a different TLS certificate, stricter rate limits, or separate authentication policies, creating a new Gateway could be a good approach.
51
79
@@ -60,7 +88,9 @@ Scaling the control plane can be beneficial in the following scenarios:
60
88
1. _Higher availability_ - When a control plane pod crashes, runs out of memory, or goes down during an upgrade, it can interrupt configuration delivery. By scaling to multiple replicas, another pod can quickly step in and take over, keeping things running smoothly with minimal downtime.
61
89
1. _Faster configuration distribution_ - As the number of connected NGINX instances grows, a single control plane pod may become a bottleneck in handling connections or streaming configuration updates. Scaling the control plane improves concurrency and responsiveness when delivering configuration over gRPC.
62
90
63
-
To scale the control plane, use the `kubectl scale` command on the control plane deployment to increase or decrease the number of replicas. For example, the following command scales the control plane deployment to 3 replicas:
91
+
To automatically scale the control plane, you can create a [Horizontal Pod Autoscaler](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/) (HPA) in the control plane namespace (default: `nginx-gateway`). At installation time, the [NGINX Gateway Fabric helm chart](https://github.com/nginx/nginx-gateway-fabric/blob/main/charts/nginx-gateway-fabric/values.yaml) allows you to set the HPA configuration in the `nginxGateway.autoscaling` section, which will provision an HPA for you. If NGINX Gateway Fabric is already running, then you can manually define the HPA and deploy it.
92
+
93
+
To manually scale the control plane, use the `kubectl scale` command on the control plane deployment to increase or decrease the number of replicas. For example, the following command scales the control plane deployment to 3 replicas:
0 commit comments