Skip to content

Commit 540a795

Browse files
Apply suggestions from code review
Co-authored-by: Alan Dooley <github@adubhlaoi.ch>
1 parent 4d1c847 commit 540a795

File tree

1 file changed

+45
-30
lines changed

1 file changed

+45
-30
lines changed

content/ngf/how-to/scaling.md

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,94 @@
11
---
2-
title: Scaling control plane and data plane
2+
title: Scaling the control plane and data plane
33
weight: 700
44
toc: true
55
type: how-to
66
product: NGF
77
docs: DOCS-0000
88
---
99

10-
Users can scale both the NGINX Gateway Fabric control plane and data planes separately. This guide walks you through how to scale each component effectively and helps you decide when to scale the data plane versus creating a new gateway, based on your traffic patterns.
10+
This document describes how you can separately scale the NGINX Gateway Fabric control plane and data plane.
11+
12+
It provides guidance on how to scale each plane effectively, and when you should do so based on your traffic patterns.
1113

12-
---
1314

1415
### Scaling the data plane
1516

16-
The data plane is the NGINX deployment that handles user traffic to backend applications.
17-
Every Gateway object that gets created results in a new NGINX deployment being provisioned with its own configuration. There are a couple of options on how to scale data plane deployments. You can do so either by increasing the number of replicas for the data plane deployment or by creating a new Gateway to provision a new data plane.
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+
19+
You have two options for scaling the data plane:
20+
21+
- Increasing the number of replicas for an existing deployment
22+
- Creating a new Gateway for a new data plane
23+
24+
#### When to increase replicas or create a new Gateway
25+
26+
Understanding when to increase replicas or create a new Gateway is key to managing traffic effectively.
1827

19-
#### When to create a new gateway vs Scale Data plane replicas
28+
Increasing data plane replicas is ideal when you need to handle more traffic without changing the configuration.
2029

21-
When using NGINX Gateway Fabric, understanding when to scale the data plane vs when to create a new gateway is key to managing traffic effectively.
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.
2231

23-
Scaling data plane replicas is ideal when you need to handle more traffic without changing the configuration. 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. All replicas will share the same configuration from the Gateway used to set up the data plane, making configuration management easy.
32+
All replicas will share the same configuration from the Gateway used to set up the data plane, simplifying configuration management.
2433

2534
There are two ways to modify the number of replicas for an NGINX deployment:
2635

27-
- Modifying the field `nginx.replicas` in the `values.yaml` or add the `--set nginx.replicas=` flag to the `helm install` command. Below is an example to do so:
36+
First, by modifying the field `nginx.replicas` in the `values.yaml` or adding the `--set nginx.replicas=` flag to the `helm install` command.
2837

29-
```text
30-
helm install ngf oci://ghcr.io/nginx/charts/nginx-gateway-fabric --create-namespace -n nginx-gateway --set nginx.replicas=5
31-
```
38+
```text
39+
helm install ngf oci://ghcr.io/nginx/charts/nginx-gateway-fabric --create-namespace -n nginx-gateway --set nginx.replicas=5
40+
Secondly, by editing the `NginxProxy` resource attached to the data plane deployment. You can specify the number of replicas in the field `kubernetes.deployment.replicas` of the nginxProxy resource:
3241
33-
- Editing the `NginxProxy` resource attached to the data plane deployment. You can specify the number of replicas in the field `kubernetes.deployment.replicas` of the nginxProxy resource:
42+
```text
43+
kubectl edit nginxproxies.gateway.nginx.org ngf-proxy-config -n nginx-gateway
3444
35-
```text
36-
kubectl edit nginxproxies.gateway.nginx.org ngf-proxy-config -n nginx-gateway
37-
```
3845
39-
The other way to scale data planes is by creating a new Gateway. This is is beneficial when you need distinct configurations, isolation, or separate policies. 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. It allows safe experimentation with isolated configurations and makes it easier to enforce security boundaries and apply specific routing rules.
46+
The alternate way to scale the data plane is by creating a new Gateway. This is is beneficial when you need distinct configurations, isolation, or separate policies.
47+
48+
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.
49+
50+
It allows for safe experimentation with isolated configurations and makes it easier to enforce security boundaries and specific routing rules.
4051
41-
---
4252
4353
### Scaling the control plane
4454
4555
The control plane builds configuration based on defined Gateway API resources and sends that configuration to the NGINX data planes. With leader election enabled by default, the control plane can be scaled horizontally by running multiple replicas, although only the pod with leader lease can actively manage configuration status updates.
4656
4757
Scaling the control plane can be beneficial in the following scenarios:
4858
49-
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.
50-
2. *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.
51-
3. *Improved Resilience* - Running multiple control plane replicas provides fault tolerance. Even if the pod holding the leader lease fails, another pod can quickly step in and take over, preventing disruptions in status updates.
59+
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.
60+
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.
61+
1. _Improved resilience_ - Running multiple control plane replicas provides fault tolerance. Even if the pod holding the leader lease fails, another pod can quickly step in and take over, preventing disruptions in status updates.
5262
5363
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:
5464
5565
```text
5666
kubectl scale deployment -n nginx-gateway ngf-nginx-gateway-fabric --replicas 3
5767
```
5868

59-
#### Known risks around scaling control plane
69+
#### Known risks when scaling the control plane
6070

6171
When scaling the control plane, it's important to understand how status updates are handled for Gateway API resources.
62-
All control plane pods can send NGINX configuration to the data planes. However, only the leader control plane pod is allowed to write status updates to Gateway API resources. This means that if an NGINX instance connects to a non-leader pod, and an error occurs when applying the config, that error status will not be written to the Gateway object status. To help mitigate the potential for this issue, ensure that the number of NGINX data plane pods equals or exceeds the number of control plane pods. This increases the likelihood that at least one of the data planes is connected to the leader control plane pod. This way if an applied configuration has an error, the leader pod will be aware of it and status can still be written.
72+
73+
All control plane pods can send NGINX configuration to the data planes. However, only the leader control plane pod is allowed to write status updates to Gateway API resources.
74+
75+
If an NGINX instance connects to a non-leader pod, and an error occurs when applying the config, that error status will not be written to the Gateway object status.
76+
77+
To mitigate the potential for this issue, ensure that the number of NGINX data plane pods equals or exceeds the number of control plane pods.
78+
79+
This increases the likelihood that at least one of the data planes is connected to the leader control plane pod. If an applied configuration has an error, the leader pod will be aware of it and status can still be written.
6380

6481
There is still a chance (however unlikely) that one of the data planes connected to a non-leader has an issue applying its configuration, while the rest of the data planes are successful, which could lead to that error status not being written.
6582

6683
To identify which control plane pod currently holds the leader election lease, retrieve the leases in the same namespace as the control plane pods. For example:
6784

68-
```text
69-
kubectl get leases -n nginx-gateway
70-
```
85+
```text
86+
kubectl get leases -n nginx-gateway
7187
7288
The current leader lease is held by the pod `ngf-nginx-gateway-fabric-b45ffc8d6-d9z2g_2ef81ced-f19d-41a0-9fcd-a68d89380d10`:
7389
74-
```text
75-
NAME HOLDER AGE
76-
ngf-nginx-gateway-fabric-leader-election ngf-nginx-gateway-fabric-b45ffc8d6-d9z2g_2ef81ced-f19d-41a0-9fcd-a68d89380d10 16d
77-
```
90+
```text
91+
NAME HOLDER AGE
92+
ngf-nginx-gateway-fabric-leader-election ngf-nginx-gateway-fabric-b45ffc8d6-d9z2g_2ef81ced-f19d-41a0-9fcd-a68d89380d10 16d
7893
7994
---

0 commit comments

Comments
 (0)