|
| 1 | +--- |
| 2 | +title: Nginx Benchmarking |
| 3 | +weight: 7 |
| 4 | + |
| 5 | +### FIXED, DO NOT MODIFY |
| 6 | +layout: learningpathall |
| 7 | +--- |
| 8 | + |
| 9 | +## Nginx Benchmarking by ApacheBench |
| 10 | + |
| 11 | +**ApacheBench (ab)** is a lightweight command-line tool for benchmarking HTTP servers. It measures performance metrics like requests per second, response time, and throughput under concurrent load. |
| 12 | + |
| 13 | +1. Install ApacheBench |
| 14 | + |
| 15 | +```console |
| 16 | +sudo dnf install httpd-tools |
| 17 | +``` |
| 18 | + |
| 19 | +2. Verify Installation |
| 20 | + |
| 21 | +```console |
| 22 | +ab -V |
| 23 | +``` |
| 24 | +You should see an output similar to: |
| 25 | + |
| 26 | +```output |
| 27 | +This is ApacheBench, Version 2.3 <$Revision: 1923142 $> |
| 28 | +Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ |
| 29 | +Licensed to The Apache Software Foundation, http://www.apache.org/ |
| 30 | +``` |
| 31 | + |
| 32 | +3. Basic Benchmark Command Syntax |
| 33 | + |
| 34 | +```console |
| 35 | +ab -n <total_requests> -c <concurrent_clients> <http://host:port/path> |
| 36 | +``` |
| 37 | +Example: |
| 38 | + |
| 39 | +```console |
| 40 | +ab -n 1000 -c 50 http://localhost/ |
| 41 | +``` |
| 42 | +This sends **1000 total requests** with **50 concurrent connections** to `http://localhost/`. |
| 43 | + |
| 44 | +You should see an output similar to: |
| 45 | +```output |
| 46 | +This is ApacheBench, Version 2.3 <$Revision: 1923142 $> |
| 47 | +Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ |
| 48 | +Licensed to The Apache Software Foundation, http://www.apache.org/ |
| 49 | +
|
| 50 | +Benchmarking localhost (be patient) |
| 51 | +Completed 100 requests |
| 52 | +Completed 200 requests |
| 53 | +Completed 300 requests |
| 54 | +Completed 400 requests |
| 55 | +Completed 500 requests |
| 56 | +Completed 600 requests |
| 57 | +Completed 700 requests |
| 58 | +Completed 800 requests |
| 59 | +Completed 900 requests |
| 60 | +Completed 1000 requests |
| 61 | +Finished 1000 requests |
| 62 | +
|
| 63 | +
|
| 64 | +Server Software: nginx/1.25.4 |
| 65 | +Server Hostname: localhost |
| 66 | +Server Port: 80 |
| 67 | +
|
| 68 | +Document Path: / |
| 69 | +Document Length: 615 bytes |
| 70 | +
|
| 71 | +Concurrency Level: 50 |
| 72 | +Time taken for tests: 0.049 seconds |
| 73 | +Complete requests: 1000 |
| 74 | +Failed requests: 0 |
| 75 | +Total transferred: 848000 bytes |
| 76 | +HTML transferred: 615000 bytes |
| 77 | +Requests per second: 20352.51 [#/sec] (mean) |
| 78 | +Time per request: 2.457 [ms] (mean) |
| 79 | +Time per request: 0.049 [ms] (mean, across all concurrent requests) |
| 80 | +Transfer rate: 16854.42 [Kbytes/sec] received |
| 81 | +
|
| 82 | +Connection Times (ms) |
| 83 | + min mean[+/-sd] median max |
| 84 | +Connect: 0 1 0.2 1 2 |
| 85 | +Processing: 0 1 0.2 1 2 |
| 86 | +Waiting: 0 1 0.3 1 2 |
| 87 | +Total: 1 2 0.1 2 3 |
| 88 | +
|
| 89 | +Percentage of the requests served within a certain time (ms) |
| 90 | + 50% 2 |
| 91 | + 66% 2 |
| 92 | + 75% 2 |
| 93 | + 80% 2 |
| 94 | + 90% 2 |
| 95 | + 95% 3 |
| 96 | + 98% 3 |
| 97 | + 99% 3 |
| 98 | + 100% 3 (longest request) |
| 99 | +``` |
| 100 | + |
| 101 | +### Benchmark Results Table Explained: |
| 102 | + |
| 103 | +- **Requests per second** – How many requests were served per second. |
| 104 | +- **Time per request** – Average latency per request. |
| 105 | +- **Transfer rate** – Data throughput. |
| 106 | +- **Connection times** – Breakdown of min/mean/max connect, processing, and total times. |
| 107 | +- **Percentage served** – Percentile distribution of response times. |
| 108 | + |
| 109 | +### Benchmark summary on x86_64: |
| 110 | + |
| 111 | +The following benchmark results are collected on two different x86_64 environments: a **Docker container running Azure Linux 3.0 hosted on a D4s_v6 Ubuntu-based Azure virtual machine**, and a **D4s_v4 Azure virtual machine created from the Azure Linux 3.0 image published by Ntegral Inc**. |
| 112 | + |
| 113 | +| **Category** | **Metric** | **Value on Virtual Machine** | **Value on Docker** | |
| 114 | +| ------------------------- | ---------------------------------------------- | ------------------- | ------------------- | |
| 115 | +| **General Info** | Server Software | nginx/1.25.4 | nginx/1.25.4 | |
| 116 | +| | Server Hostname | localhost | localhost | |
| 117 | +| | Server Port | 80 | 80 | |
| 118 | +| | Document Path | / | / | |
| 119 | +| | Document Length | 615 bytes | 615 bytes | |
| 120 | +| **Test Setup** | Concurrency Level | 50 | 50 | |
| 121 | +| | Time Taken for Tests | 0.049 sec | 0.027 sec | |
| 122 | +| | Complete Requests | 1000 | 1000 | |
| 123 | +| | Failed Requests | 0 | 0 | |
| 124 | +| **Transfer Stats** | Total Transferred | 848000 bytes | 848000 bytes | |
| 125 | +| | HTML Transferred | 615000 bytes | 615000 bytes | |
| 126 | +| | Requests per Second | 20,352.51 [#/sec] | 37,510.78 [#/sec] | |
| 127 | +| | Time per Request (mean) | 2.457 ms | 1.333 ms | |
| 128 | +| | Time per Request (across all) | 0.049 ms | 0.027 ms | |
| 129 | +| | Transfer Rate | 16,854.42 KB/sec | 31,063.62 KB/sec | |
| 130 | +| **Connection Times (ms)** | Connect (min / mean / stdev / median / max) | 0 / 1 / 0.2 / 1 / 2 | 0 / 0 / 0.1 / 0 / 1 | |
| 131 | +| | Processing (min / mean / stdev / median / max) | 0 / 1 / 0.2 / 1 / 2 | 0 / 1 / 0.2 / 1 / 1 | |
| 132 | +| | Waiting (min / mean / stdev / median / max) | 0 / 1 / 0.3 / 1 / 2 | 0 / 1 / 0.2 / 1 / 1 | |
| 133 | +| | Total (min / mean / stdev / median / max) | 1 / 2 / 0.1 / 2 / 3 | 1 / 1 / 0.1 / 1 / 2 | |
| 134 | + |
| 135 | + |
| 136 | +### Benchmark summary on Arm64: |
| 137 | + |
| 138 | +The following benchmark results are collected on two different Arm64 environments: a **Docker container running Azure Linux 3.0 hosted on a D4ps_v6 Ubuntu-based Azure virtual machine**, and a **D4ps_v6 Azure virtual machine created from the Azure Linux 3.0 custom image using the AArch64 ISO**. |
| 139 | + |
| 140 | +| **Category** | **Metric** | **Value on Virtual Machine** | **Value on Docker** | |
| 141 | +|---------------------------|--------------------------------------------------|--------------------------|---------------------------| |
| 142 | +| **General Info** | Server Software | nginx/1.25.4 | nginx/1.25.4 | |
| 143 | +| | Server Hostname | localhost | localhost | |
| 144 | +| | Server Port | 80 | 80 | |
| 145 | +| | Document Path | / | / | |
| 146 | +| | Document Length | 615 bytes | 615 bytes | |
| 147 | +| **Test Setup** | Concurrency Level | 50 | 50 | |
| 148 | +| | Time Taken for Tests | 0.032 sec | 0.025 sec | |
| 149 | +| | Complete Requests | 1000 | 1000 | |
| 150 | +| | Failed Requests | 0 | 0 | |
| 151 | +| **Transfer Stats** | Total Transferred | 848000 bytes | 848000 bytes | |
| 152 | +| | HTML Transferred | 615000 bytes | 615000 bytes | |
| 153 | +| | Requests per Second | 30,876.59 [#/sec] | 40,698.38 [#/sec] | |
| 154 | +| | Time per Request (mean) | 1.619 ms | 1.229 ms | |
| 155 | +| | Time per Request (across all) | 0.032 ms | 0.025 ms | |
| 156 | +| | Transfer Rate | 25,569.67 KB/sec | 33,703.35 KB/sec | |
| 157 | +| **Connection Times (ms)** | Connect (min / mean / stdev / median / max) | 0 / 1 / 0.1 / 1 / 1 | 0 / 0 / 0.1 / 0 / 1 | |
| 158 | +| | Processing (min / mean / stdev / median / max) | 0 / 1 / 0.1 / 1 / 2 | 0 / 1 / 0.1 / 1 / 1 | |
| 159 | +| | Waiting (min / mean / stdev / median / max) | 0 / 1 / 0.2 / 1 / 1 | 0 / 1 / 0.1 / 1 / 1 | |
| 160 | +| | Total (min / mean / stdev / median / max) | 1 / 2 / 0.1 / 2 / 2 | 1 / 1 / 0.1 / 1 / 1 | |
| 161 | + |
| 162 | + |
| 163 | +### Highlights from Azure Linux Arm64 Benchmarking |
| 164 | + |
| 165 | +- Achieved **30,876.59 requests/sec**, significantly outperforming x86_64 (20,352.51 requests/sec). |
| 166 | +- Response time per request averaged **1.619 ms**, indicating high efficiency under 50 concurrent connections. |
| 167 | +- **Zero failed requests**, ensuring full stability during the stress test. |
| 168 | +- Consistently low **connection and processing times** (mean ≈ 1 ms). |
0 commit comments