Skip to content

Commit 90ef887

Browse files
authored
Merge pull request #2262 from pareenaverma/content_review
Tech review of Tomcat tuning LP
2 parents c50d228 + c36f301 commit 90ef887

File tree

7 files changed

+106
-101
lines changed

7 files changed

+106
-101
lines changed

content/learning-paths/servers-and-cloud-computing/tune-network-workloads-on-bare-metal/1_setup.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Tomcat benchmark set up
2+
title: Set up Tomcat
33
weight: 2
44

55
### FIXED, DO NOT MODIFY
@@ -9,16 +9,16 @@ layout: learningpathall
99

1010
## Overview
1111

12-
There are numerouse client-server and network-based workloads, and Tomcat is a typical example of such applications, which provide services via HTTP/HTTPS network requests.
12+
There are numerous client-server and network-based workloads, with Tomcat being a typical example of such applications. Tomcat provides services via HTTP/HTTPS network requests.
1313

14-
In this section, you'll set up a benchmark environment using `Apache Tomcat` and `wrk2` to simulate HTTP load and evaluate performance on an Arm-based bare-metal, such as **__`AWS c8g.metal-48xl`__**.
14+
In this section, you will set up a benchmark environment using `Apache Tomcat` and `wrk2` to simulate an HTTP load and evaluate performance on an Arm-based bare metal instance. This Learning Path was tested on an AWS `c8g.metal-48xl` instance.
1515

16-
## Set up the Tomcat benchmark server on **AWS c8g.metal-48xl**
16+
## Set up the Tomcat benchmark server
1717
[Apache Tomcat](https://tomcat.apache.org/) is an open-source Java Servlet container that runs Java web applications, handles HTTP requests, and serves dynamic content. It supports technologies such as Servlet, JSP, and WebSocket.
1818

1919
## Install the Java Development Kit (JDK)
2020

21-
Install OpenJDK 21 on your Arm-based Ubuntu 24 bare-metal:
21+
Install OpenJDK 21 on your Arm-based Ubuntu 24.04 bare-metal instance:
2222

2323
```bash
2424
sudo apt update
@@ -44,13 +44,16 @@ The file is at:
4444
~/apache-tomcat-11.0.10/webapps/examples/META-INF/context.xml
4545
```
4646

47+
Replace the existing allow value as shown:
4748
```xml
48-
<!-- Before -->
4949
<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
50+
```
5051

51-
<!-- After -->
52+
With:
53+
```xml
5254
<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow=".*" />
5355
```
56+
Save the changes to your file.
5457

5558
## Start the Tomcat server
5659
{{% notice Note %}}
@@ -91,7 +94,7 @@ You should see the Tomcat welcome page and examples, as shown below:
9194
[Wrk2](https://github.com/giltene/wrk2) is a high-performance HTTP benchmarking tool specialized in generating constant throughput loads and measuring latency percentiles for web services. `wrk2` is an enhanced version of `wrk` that provides accurate latency statistics under controlled request rates, ideal for performance testing of HTTP servers.
9295

9396
{{% notice Note %}}
94-
Currently `wrk2` is only supported on x86 machines. Run the benchmark client steps below on an `x86_64` server running Ubuntu 24.
97+
Currently `wrk2` is only supported on x86 machines. Run the benchmark client steps below on a bare metal `x86_64` server running Ubuntu 24.04
9598
{{% /notice %}}
9699

97100
## Install dependencies

content/learning-paths/servers-and-cloud-computing/tune-network-workloads-on-bare-metal/2_baseline.md

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Optimal baseline before tuning
2+
title: Establish baseline performance
33
weight: 3
44

55
### FIXED, DO NOT MODIFY
@@ -11,59 +11,59 @@ To achieve maximum performance, ulimit -n 65535 must be executed on both server
1111
{{% /notice %}}
1212

1313
## Optimal baseline before tuning
14-
- Align the IOMMU settings with default Ubuntu
14+
- Align the IOMMU settings with default Ubuntu settings
1515
- Baseline on Arm Neoverse bare-metal (default configuration)
1616
- Baseline on Arm Neoverse bare-metal (access logging disabled)
1717
- Baseline on Arm Neoverse bare-metal (optimal thread count)
1818

19-
### Align the IOMMU settings with default Ubuntu
19+
### Align the IOMMU settings with default Ubuntu settings
2020

2121
{{% notice Note %}}
22-
Due to the customized Ubuntu distribution on AWS, you first need to align the IOMMU settings with default Ubuntu: iommu.strict=1 and iommu.passthrough=0.
22+
As you are using a custom Ubuntu distribution on AWS, you will first need to align the IOMMU settings with default Ubuntu settings for IOMMU: iommu.strict=1 and iommu.passthrough=0.
2323
{{% /notice %}}
2424

25-
1. Setting IOMMU default status, use a text editor to modify the `grub` file by adding or updating the `GRUB_CMDLINE_LINUX` configuration.
25+
1. To change the IOMMU settings, use a text editor to modify the `grub` file by adding or updating the `GRUB_CMDLINE_LINUX` configuration:
2626

2727
```bash
2828
sudo vi /etc/default/grub
2929
```
30-
then add or update
30+
Depending on what's in your `grub` file you will need to add or update `GRUB_CMDLINE_LINUX`:
3131
```bash
3232
GRUB_CMDLINE_LINUX="iommu.strict=1 iommu.passthrough=0"
3333
```
3434

35-
2. Update GRUB and reboot to apply the default settings.
35+
2. Update GRUB and reboot your system to apply the default settings.
3636
```bash
3737
sudo update-grub && sudo reboot
3838
```
3939

40-
3. Verify whether the default settings have been successfully applied.
40+
3. Verify that the default settings have been successfully applied:
4141
```bash
4242
sudo dmesg | grep iommu
4343
```
44-
It can be observed that under the default configuration, iommu.strict is enabled, and iommu.passthrough is disabled.
45-
```bash
44+
You should see that under the default configuration, `iommu.strict` is enabled, and `iommu.passthrough` is disabled:
45+
```output
4646
[ 0.877401] iommu: Default domain type: Translated (set via kernel command line)
4747
[ 0.877404] iommu: DMA domain TLB invalidation policy: strict mode (set via kernel command line)
4848
...
4949
```
5050

51-
### Baseline on Arm Neoverse bare-metal (default configuration)
51+
### Establish a baseline configuration on Arm Neoverse bare-metal instances
5252

5353
{{% notice Note %}}
54-
To align with the typical deployment scenario of Tomcat, reserve 8 cores online and set all other cores offline
54+
To align with typical deployment scenario of Tomcat, you will need to reserve 8 cores on your instance to be online and set all other cores to be offline
5555
{{% /notice %}}
5656

57-
1. You can offline the CPU cores using the below command.
57+
1. To set the remaining CPU cores on your instance to be offline, run:
5858
```bash
5959
for no in {8..191}; do sudo bash -c "echo 0 > /sys/devices/system/cpu/cpu${no}/online"; done
6060
```
6161
2. Use the following commands to verify that cores 0-7 are online and the remaining cores are offline.
6262
```bash
6363
lscpu
6464
```
65-
You can check the following information:
66-
```bash
65+
The output should look like:
66+
```output
6767
Architecture: aarch64
6868
CPU op-mode(s): 64-bit
6969
Byte Order: Little Endian
@@ -75,22 +75,21 @@ Vendor ID: ARM
7575
...
7676
```
7777

78-
3. Use the following command on the Arm Neoverse bare-metal where `Tomcat` is on
78+
3. Now shutdown and restart `Tomcat` on your Arm Neoverse bare-metal instance as shown:
7979
```bash
8080
~/apache-tomcat-11.0.10/bin/shutdown.sh 2>/dev/null
8181
ulimit -n 65535 && ~/apache-tomcat-11.0.10/bin/startup.sh
8282
```
8383

84-
4. And use the following command on the `x86_64` bare-metal where `wrk2` is on
85-
```bash
86-
tomcat_ip=172.31.46.193
87-
```
84+
4. On your `x86_64` bare-metal instance, run `wrk2` as shown:
85+
8886
```bash
8987
ulimit -n 65535 && wrk -c1280 -t128 -R500000 -d60 http://${tomcat_ip}:8080/examples/servlets/servlet/HelloWorldExample
9088
```
89+
Replace `{tomcat_ip}` in the command above with the IP address of your Arm-based instance where the Tomcat server is running.
9190

92-
The result of default configuration is:
93-
```bash
91+
The result with this baseline configuration should look like:
92+
```output
9493
Thread Stats Avg Stdev Max +/- Stdev
9594
Latency 16.76s 6.59s 27.56s 56.98%
9695
Req/Sec 1.97k 165.05 2.33k 89.90%
@@ -100,15 +99,15 @@ Requests/sec: 244449.62
10099
Transfer/sec: 129.90MB
101100
```
102101

103-
### Baseline on Arm Neoverse bare-metal (access logging disabled)
104-
To disable the access logging, use a text editor to modify the `server.xml` file by commenting out or removing the **`org.apache.catalina.valves.AccessLogValve`** configuration.
102+
### Disable Access logging
103+
To disable access logging, use a text editor to modify the `server.xml` file by commenting out or removing the **`org.apache.catalina.valves.AccessLogValve`** configuration.
105104

106105
The file is at:
107106
```bash
108107
vi ~/apache-tomcat-11.0.10/conf/server.xml
109108
```
110109

111-
The configuratin is at the end of the file, and common out or remove it.
110+
Either comment out or delete the configuration shown at the end of the file:
112111
```xml
113112
<!--
114113
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
@@ -117,18 +116,18 @@ The configuratin is at the end of the file, and common out or remove it.
117116
-->
118117
```
119118

120-
1. Use the following command on the Arm Neoverse bare-metal where `Tomcat` is on
119+
1. Shutdown and restart `Tomcat` on your Arm Neoverse bare-metal instance as shown:
121120
```bash
122121
~/apache-tomcat-11.0.10/bin/shutdown.sh 2>/dev/null
123122
ulimit -n 65535 && ~/apache-tomcat-11.0.10/bin/startup.sh
124123
```
125124

126-
2. And use the following command on the `x86_64` bare-metal where `wrk2` is on
125+
2. Run `wrk2` on the `x86_64` bare-metal instance:
127126
```bash
128127
ulimit -n 65535 && wrk -c1280 -t128 -R500000 -d60 http://${tomcat_ip}:8080/examples/servlets/servlet/HelloWorldExample
129128
```
130129

131-
The result of access logging disabled is:
130+
The result with access logging disabled should look like:
132131
```bash
133132
Thread Stats Avg Stdev Max +/- Stdev
134133
Latency 16.16s 6.45s 28.26s 57.85%
@@ -139,15 +138,15 @@ Requests/sec: 271675.12
139138
Transfer/sec: 144.36MB
140139
```
141140

142-
### Baseline on Arm Neoverse bare-metal (optimal thread count)
141+
### Set up optimal thread counts
143142
To minimize resource contention between threads and overhead from thread context switching, the number of CPU-intensive threads in Tomcat should be aligned with the number of CPU cores.
144143

145-
1. When using `wrk` to perform pressure testing on `Tomcat`:
144+
1. When using `wrk` to perform pressure testing on `Tomcat`, use `top` to identify the CPU-intensive threads :
146145
```bash
147146
top -H -p$(pgrep java)
148147
```
149148

150-
You can see the below information
149+
The output from `top` will look like:
151150
```bash
152151
top - 08:57:29 up 20 min, 1 user, load average: 4.17, 2.35, 1.22
153152
Threads: 231 total, 8 running, 223 sleeping, 0 stopped, 0 zombie
@@ -184,24 +183,26 @@ MiB Swap: 0.0 total, 0.0 free, 0.0 used. 382087.0 avail Mem
184183
...
185184
```
186185

187-
It can be observed that **`http-nio-8080-e`** and **`http-nio-8080-P`** threads are CPU-intensive.
188-
Since the __`http-nio-8080-P`__ thread is fixed at 1 in current version of Tomcat, and the current number of CPU cores is 8, the http-nio-8080-e thread count should be configured to 7.
186+
You can observe from the output that **`http-nio-8080-e`** and **`http-nio-8080-P`** threads are CPU-intensive.
187+
As the __`http-nio-8080-P`__ thread is fixed at 1 in current version of Tomcat, and the current number of CPU cores is 8, the `http-nio-8080-e` thread count should be configured to 7.
189188

190-
To configure the `http-nio-8080-e` thread count, use a text editor to modify the `context.xml` file by updating the `<Connector port="8080" protocol="HTTP/1.1"` configuration.
189+
To configure the `http-nio-8080-e` thread count, use a text editor to modify the `server.xml` file and update the `<Connector port="8080" protocol="HTTP/1.1"` configuration.
191190

192191
The file is at:
193192
```bash
194193
vi ~/apache-tomcat-11.0.10/conf/server.xml
195194
```
196195

197-
196+
Replace the existing Connector setting as shown:
198197
```xml
199198
<!-- Before -->
200199
<Connector port="8080" protocol="HTTP/1.1"
201200
connectionTimeout="20000"
202201
redirectPort="8443" />
203202
```
204203

204+
With the updated setting:
205+
205206
```xml
206207
<!-- After -->
207208
<Connector port="8080" protocol="HTTP/1.1"
@@ -214,23 +215,27 @@ vi ~/apache-tomcat-11.0.10/conf/server.xml
214215
/>
215216
```
216217

217-
2. Use the following command on the Arm Neoverse bare-metal where `Tomcat` is on
218+
Save the changes to `server.xml`.
219+
220+
2. Now shutdown and restart `Tomcat` on your Arm Neoverse bare-metal instance as shown:
218221
```bash
219222
~/apache-tomcat-11.0.10/bin/shutdown.sh 2>/dev/null
220223
ulimit -n 65535 && ~/apache-tomcat-11.0.10/bin/startup.sh
221224
```
222225

223-
3. And use the following command on the `x86_64` bare-metal where `wrk2` is on
226+
3. Run `wrk2` on the`x86_64` bare-metal instance:
224227
```bash
225228
ulimit -n 65535 && wrk -c1280 -t128 -R500000 -d60 http://${tomcat_ip}:8080/examples/servlets/servlet/HelloWorldExample
226229
```
227230

228-
The result of optimal thread count is:
229-
```bash
231+
The result with the optimal thread count settings should look like:
232+
```output
230233
Thread Stats Avg Stdev Max +/- Stdev
231234
Latency 10.26s 4.55s 19.81s 62.51%
232235
Req/Sec 2.86k 89.49 3.51k 77.06%
233236
21458421 requests in 1.00m, 11.13GB read
234237
Requests/sec: 357835.75
235238
Transfer/sec: 190.08MB
236239
```
240+
241+
Now that you have established some baseline settings you can proceed to further tuning your setup.

content/learning-paths/servers-and-cloud-computing/tune-network-workloads-on-bare-metal/3_nic-queue.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ layout: learningpathall
77
---
88

99
## Tuning via NIC queue count
10-
- Setting NIC queue count
11-
- The result after tuning NIC queue count
10+
To further optmize your settings, you can set the NIC queue count and observe the performance uplift:
1211

1312
Typically, the number of transmit/receive queues for network cards in bare-metal environments is relatively large, reaching 63 on Arm Neoverse. Each transmit/receive queue corresponds to one interrupt number. Before CPU cores are taken offline, there are sufficient cores to handle these interrupt numbers. However, when only 8 cores are retained, it results in a single core having to handle multiple interrupt numbers, thereby triggering more context switches.
1413

@@ -18,8 +17,8 @@ Typically, the number of transmit/receive queues for network cards in bare-metal
1817
```bash
1918
ip addr
2019
```
21-
It can be observed that the NIC name `enp1s0f0np0` corresponsed to the IP address `10.169.226.181`.
22-
```bash
20+
From the output you can see that the NIC name `enp1s0f0np0` corresponds to the IP address `10.169.226.181`.
21+
```output
2322
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
2423
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2524
inet 127.0.0.1/8 scope host lo
@@ -66,8 +65,8 @@ sudo ethtool -L ${net} combined 8
6665
```bash
6766
sudo ethtool -l ${net}
6867
```
69-
It can be observed that the number of combined Rx/Tx queues has been updated to 8.
70-
```bash
68+
You should see that the number of combined Rx/Tx queues has been updated to 8.
69+
```output
7170
Channel parameters for enP11p4s0:
7271
Pre-set maximums:
7372
RX: n/a
@@ -81,21 +80,21 @@ Other: n/a
8180
Combined: 8
8281
```
8382

84-
### The result after tuning NIC queue count
83+
### The performance uplift after tuning NIC queue count
8584

86-
1. Use the following command on the Arm Neoverse bare-metal where `Tomcat` is on
85+
1. Shutdown and restart `Tomcat` on your Arm Neoverse bare-metal instance as shown:
8786
```bash
8887
~/apache-tomcat-11.0.10/bin/shutdown.sh 2>/dev/null
8988
ulimit -n 65535 && ~/apache-tomcat-11.0.10/bin/startup.sh
9089
```
9190

92-
2. And use the following command on the `x86_64` bare-metal where `wrk2` is on
91+
2. Run `wrk2` on your `x86_64` bare-metal instance:
9392
```bash
9493
ulimit -n 65535 && wrk -c1280 -t128 -R500000 -d60 http://${tomcat_ip}:8080/examples/servlets/servlet/HelloWorldExample
9594
```
9695

97-
The result after NIC queue count tuned:
98-
```bash
96+
Notice the performance uplift after tuning the NIC queue count:
97+
```output
9998
Thread Stats Avg Stdev Max +/- Stdev
10099
Latency 8.35s 4.14s 16.33s 61.16%
101100
Req/Sec 2.96k 73.02 3.24k 89.16%

0 commit comments

Comments
 (0)