Skip to content

Commit c30cbab

Browse files
making some formatting adjustments and adding per-page descriptions
1 parent a642174 commit c30cbab

4 files changed

Lines changed: 74 additions & 90 deletions

File tree

content/learning-paths/servers-and-cloud-computing/nginx_tune/kernel_comp_lib.md

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
22
title: Tune kernel, compiler, and library settings for performance
3+
description: Tune Linux network settings and evaluate compiler, OpenSSL, PCRE, and zlib choices that can affect NGINX performance on Arm-based platforms.
34
weight: 3
45
layout: "learningpathall"
56
---
67

7-
## Kernel configuration
8+
## Optimize kernel network stack settings
89

910
NGINX tuning doesn't stop at `nginx.conf`. Foundational settings such as kernel network queues, socket buffers, compiler choices, and TLS libraries can affect throughput and latency. Treat these settings as part of the same measurement process you use for NGINX directives.
1011

@@ -34,32 +35,25 @@ sudo sysctl -w net.ipv4.tcp_wmem="4096 8388608 8388608"
3435

3536
These values are intentionally large. Size them for your expected connection rate, request pattern, and available memory.
3637

37-
- `net.core.somaxconn`:
38-
- Selects the maximum number of queued connections the kernel allows.
39-
- If the NGINX server needs to support a large number of clients, it can be helpful to increase this parameter.
40-
- A value of 65535 is likely excessive for many deployments. In practice, this value needs to be large enough to support the peak number of queued connections.
41-
- `net.core.rmem_max`:
42-
- Selects the maximum read socket buffer size.
43-
- `8 MiB` is likely more than enough for most use cases.
44-
- Use a tool such as `ss` to check socket buffer utilization and set a value for this parameter.
45-
- `net.core.wmem_max`:
46-
- Selects the maximum write socket buffer size.
47-
- `8 MiB` is likely more than enough for most use cases.
48-
- Use a tool such as `ss` to check socket buffer utilization and set a value for this parameter.
49-
- `net.ipv4.tcp_max_syn_backlog`:
50-
- Selects the maximum number of connection requests that are pending but not established yet.
51-
- A value of 65535 is likely excessive for many deployments. In practice, this value needs to be large enough to support the peak number of pending connection requests.
52-
- `net.ipv4.ip_local_port_range`:
53-
- Selects the range of local ports the kernel can use.
54-
- The example expands the port range. The default range is sufficient for many deployments.
55-
- `net.ipv4.tcp_rmem`:
56-
- Selects the TCP read socket buffer size.
57-
- `8 MiB` is likely more than enough for most use cases.
58-
- Use a tool such as `ss` to check TCP buffer utilization and set a value for this parameter.
59-
- `net.ipv4.tcp_wmem`:
60-
- Selects the TCP write socket buffer size.
61-
- `8 MiB` is likely more than enough for most use cases.
62-
- Use a tool such as `ss` to check TCP buffer utilization and set a value for this parameter.
38+
- `net.core.somaxconn`: Selects the maximum number of queued connections the kernel allows. If the NGINX server needs to support a large number of clients, it can be helpful to increase this parameter.
39+
40+
A value of 65535 is likely excessive for many deployments. In practice, this value needs to be large enough to support the peak number of queued connections.
41+
- `net.core.rmem_max`: Selects the maximum read socket buffer size. `8 MiB` is likely more than enough for most use cases.
42+
43+
Use a tool such as `ss` to check socket buffer utilization and set a value for this parameter.
44+
- `net.core.wmem_max`: Selects the maximum write socket buffer size. `8 MiB` is likely more than enough for most use cases.
45+
46+
Use a tool such as `ss` to check socket buffer utilization and set a value for this parameter.
47+
- `net.ipv4.tcp_max_syn_backlog`: Selects the maximum number of connection requests that are pending but not established yet.
48+
49+
A value of 65535 is likely excessive for many deployments. In practice, this value needs to be large enough to support the peak number of pending connection requests.
50+
- `net.ipv4.ip_local_port_range`: Selects the range of local ports the kernel can use. The example expands the port range. The default range is sufficient for many deployments.
51+
- `net.ipv4.tcp_rmem`: Selects the TCP read socket buffer size. `8 MiB` is likely more than enough for most use cases.
52+
53+
Use a tool such as `ss` to check TCP buffer utilization and set a value for this parameter.
54+
- `net.ipv4.tcp_wmem`: Selects the TCP write socket buffer size. `8 MiB` is likely more than enough for most use cases.
55+
56+
Use a tool such as `ss` to check TCP buffer utilization and set a value for this parameter.
6357

6458
## Compiler considerations
6559

@@ -95,4 +89,4 @@ NGINX relies on [zlib](https://zlib.net/) for HTTP response compression when the
9589

9690
You've now learned about different kernel, compiler, and library optimizations that you can make to tune NGINX performance.
9791

98-
Next, you'll review the configuration for a static file server and learn about optimizations that you can make.
92+
Next, you'll review the configuration for a static file server and learn about optimizations that you can make.

content/learning-paths/servers-and-cloud-computing/nginx_tune/test_optimizations.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: Test NGINX optimizations
3+
description: Build wrk and run repeatable load tests against NGINX workloads on Arm-based platforms to compare tuning results.
34
weight: 6
45
layout: "learningpathall"
56
---
@@ -47,7 +48,8 @@ You can also run `wrk` directly against NGINX file servers, or run `wrk` on the
4748

4849
### Run a wrk test
4950

50-
The NGINX file servers need files to serve. If you are using the configuration files discussed in [Tune a static file server](/learning-paths/servers-and-cloud-computing/nginx_tune/tune_static_file_server/) or [Tune a reverse proxy or API gateway](/learning-paths/servers-and-cloud-computing/nginx_tune/tune_revprox_and_apigw/), run the following commands on each file server to create sample files. You do not need to create these files on reverse proxy or API gateway nodes because they do not serve files directly.
51+
The NGINX file servers need files to serve. If you're using the configuration files discussed in [Tune a static file server](/learning-paths/servers-and-cloud-computing/nginx_tune/tune_static_file_server/) or [Tune a reverse proxy or API gateway](/learning-paths/servers-and-cloud-computing/nginx_tune/tune_revprox_and_apigw/), run the following commands on each file server to create sample files:
52+
5153

5254
```bash
5355
# Create 1 KB file in the reverse proxy use case directory
@@ -66,6 +68,8 @@ sudo cp /usr/share/nginx/html/5kb /usr/share/nginx/html/api_new
6668
sudo cp /usr/share/nginx/html/10kb /usr/share/nginx/html/api_new
6769
```
6870

71+
You don't need to create these files on reverse proxy or API gateway nodes because they don't serve files directly.
72+
6973
Run the sample commands from the `wrk` build directory, or use the full path to the `wrk` binary.
7074

7175
The following sample command tests a file server or reverse proxy. Select thread and connection values that load the NGINX server without causing connection, read, or write errors in `wrk` or NGINX. Because `wrk` does not use a fixed request-rate option, adjust `-t`, `-c`, and `-d` to scale load and keep the same values when comparing configurations.
@@ -86,4 +90,4 @@ The API gateway shown in [Tune a reverse proxy or API gateway](/learning-paths/s
8690

8791
You've now used `wrk` to run an NGINX performance test.
8892

89-
You can use the guidance in this Learning Path to optimize the performance of your NGINX workloads on Arm-based platforms.
93+
You can use the guidance in this Learning Path to optimize the performance of your NGINX workloads on Arm-based platforms.

content/learning-paths/servers-and-cloud-computing/nginx_tune/tune_revprox_and_apigw.md

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
title: Tune a reverse proxy or API gateway for performance
2+
title: Tune an NGINX reverse proxy or API gateway
3+
description: Tune NGINX reverse proxy and API gateway directives for Arm-based platforms so upstream keepalive, rewrites, and caching decisions match your workload.
34
weight: 5
45
layout: "learningpathall"
56
---
@@ -65,28 +66,23 @@ server {
6566

6667
The following are performance-relevant directives that weren't discussed in the [static file server section](/learning-paths/servers-and-cloud-computing/nginx_tune/tune_static_file_server/):
6768

68-
- [`keepalive`](https://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive):
69-
- Controls the cache of idle connections to upstream servers.
70-
- For NGINX 1.29.7 and later, upstream keepalive is enabled by default with a small cache. Set `keepalive` explicitly when you want to tune the upstream idle connection cache for your workload.
71-
- For older NGINX versions, enable upstream keepalive with the `keepalive` directive. Also set [`proxy_http_version`](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_http_version) to `1.1` and clear the `Connection` header with [`proxy_set_header`](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_set_header).
72-
- The value `1024` is a cache size for idle upstream connections per worker, not a total upstream connection limit. Keep this value small enough that upstream servers can still accept new connections.
73-
- [`rewrite`](https://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite):
74-
- Rewrites the old API path to the internal API path.
75-
- Regular expression-heavy configurations can make PCRE performance more important, as discussed in [Kernel, compiler, and libraries](/learning-paths/servers-and-cloud-computing/nginx_tune/kernel_comp_lib/).
76-
- [`proxy_pass`](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass):
77-
- Forwards matching requests to the upstream server group.
78-
- Use the same upstream block for related locations when you want them to share the same upstream connection pool.
79-
- [`internal`](https://nginx.org/en/docs/http/ngx_http_core_module.html#internal) and [`limit_except`](https://nginx.org/en/docs/http/ngx_http_core_module.html#limit_except):
80-
- Included for request handling and access control, not as primary performance settings.
81-
- [`proxy_cache_path`](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_path):
82-
- Not in the example configuration, but it's worth considering when responses can be cached by the reverse proxy or API gateway.
83-
- When you use this directive, review [`proxy_cache_lock`](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_lock) and [`proxy_cache_valid`](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_valid).
84-
- For more information, see the NGINX Admin Guide section on [content caching](https://docs.nginx.com/nginx/admin-guide/content-cache/content-caching/).
85-
- NGINX variables:
86-
- The example uses `$hostname` in `server_name`. For the full list of built-in variables, see the NGINX [variable index](https://nginx.org/en/docs/varindex.html) .
69+
- [`keepalive`](https://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive): Controls the cache of idle connections to upstream servers. For NGINX 1.29.7 and later, upstream keepalive is enabled by default with a small cache. Set `keepalive` explicitly when you want to tune the upstream idle connection cache for your workload.
70+
71+
For older NGINX versions, enable upstream keepalive with the `keepalive` directive. Also set [`proxy_http_version`](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_http_version) to `1.1` and clear the `Connection` header with [`proxy_set_header`](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_set_header).
72+
73+
The value `1024` is a cache size for idle upstream connections per worker, not a total upstream connection limit. Keep this value small enough that upstream servers can still accept new connections.
74+
- [`rewrite`](https://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite): Rewrites the old API path to the internal API path. Regular expression-heavy configurations can make PCRE performance more important, as discussed in [Kernel, compiler, and libraries](/learning-paths/servers-and-cloud-computing/nginx_tune/kernel_comp_lib/).
75+
- [`proxy_pass`](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass): Forwards matching requests to the upstream server group. Use the same upstream block for related locations when you want them to share the same upstream connection pool.
76+
- [`internal`](https://nginx.org/en/docs/http/ngx_http_core_module.html#internal) and [`limit_except`](https://nginx.org/en/docs/http/ngx_http_core_module.html#limit_except): Included for request handling and access control, not as primary performance settings.
77+
- [`proxy_cache_path`](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_path): Not in the example configuration, but it's worth considering when responses can be cached by the reverse proxy or API gateway.
78+
79+
When you use this directive, review [`proxy_cache_lock`](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_lock) and [`proxy_cache_valid`](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_valid).
80+
81+
For more information, see the NGINX Admin Guide section on [content caching](https://docs.nginx.com/nginx/admin-guide/content-cache/content-caching/).
82+
- NGINX variables: The example uses `$hostname` in `server_name`. For the full list of built-in variables, see the NGINX [variable index](https://nginx.org/en/docs/varindex.html).
8783

8884
## What you've learned and what's next
8985

9086
You've seen an example reverse proxy and API gateway configuration and learned about performance-relevant directives that you can optimize to tune NGINX performance.
9187

92-
Next, you'll test NGINX optimizations.
88+
Next, you'll test NGINX optimizations.

0 commit comments

Comments
 (0)