Skip to content

Commit afd5e21

Browse files
authored
NGF: Update scaling documentation and API (#932)
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.
1 parent c8ccf94 commit afd5e21

File tree

3 files changed

+472
-25
lines changed

3 files changed

+472
-25
lines changed

content/ngf/how-to/scaling.md

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,64 @@ It provides guidance on how to scale each plane effectively, and when you should
1616

1717
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.
1818

19-
You have two options for scaling the data plane:
19+
You have multiple options for scaling the data plane:
2020

21+
- Increasing the number of [worker connections](https://nginx.org/en/docs/ngx_core_module.html#worker_connections) for an existing deployment
2122
- Increasing the number of replicas for an existing deployment
2223
- Creating a new Gateway for a new data plane
2324

24-
#### When to increase replicas or create a new Gateway
25+
#### When to increase worker connections, replicas, or create a new Gateway
2526

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

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

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).
3132

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:
3334

34-
There are two ways to modify the number of replicas for an NGINX deployment:
35+
```shell
36+
kubectl edit nginxproxies.gateway.nginx.org ngf-proxy-config -n nginx-gateway
37+
```
3538

36-
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:
39+
{{< call-out "note" >}}
3740

38-
```shell
39-
helm install ngf oci://ghcr.io/nginx/charts/nginx-gateway-fabric --create-namespace -n nginx-gateway --set nginx.replicas=5
41+
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
4050
```
4151
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:
4353

44-
```shell
45-
kubectl edit nginxproxies.gateway.nginx.org ngf-proxy-config -n nginx-gateway
54+
```yaml
55+
spec:
56+
kubernetes:
57+
deployment:
58+
replicas: 3
59+
```
60+
61+
- 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
4670
```
4771

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

5078
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.
5179

@@ -60,7 +88,9 @@ Scaling the control plane can be beneficial in the following scenarios:
6088
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.
6189
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.
6290

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:
6494

6595
```shell
6696
kubectl scale deployment -n nginx-gateway ngf-nginx-gateway-fabric --replicas 3

content/ngf/overview/gateway-api-compatibility.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,11 @@ See the [controller]({{< ref "/ngf/reference/cli-help.md#controller">}}) command
136136
- `ResolvedRefs/True/ResolvedRefs`
137137
- `ResolvedRefs/False/InvalidCertificateRef`
138138
- `ResolvedRefs/False/InvalidRouteKinds`
139+
- `ResolvedRefs/False/RefNotPermitted`
139140
- `Conflicted/True/ProtocolConflict`
140141
- `Conflicted/True/HostnameConflict`
141142
- `Conflicted/False/NoConflicts`
143+
- `OverlappingTLSConfig/True/OverlappingHostnames`
142144

143145
### HTTPRoute
144146

0 commit comments

Comments
 (0)