Skip to content

Commit 65e887e

Browse files
committed
nginx/perf
1 parent d27a118 commit 65e887e

File tree

2 files changed

+139
-0
lines changed

2 files changed

+139
-0
lines changed

scripts/stunnel-perf/benchmark.sh

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/bin/bash
2+
# Set a machine into benchmarking mode.
3+
#
4+
# For native Linux, and Intel-only for now (AMD has a different way of disabling turbo)
5+
#
6+
# References: https://llvm.org/docs/Benchmarking.html
7+
8+
# This is for Fedora 42, adapt for your own OS
9+
declare -a packages=(
10+
"cpupower" "tuned" "ss" "turbostat" "lscpu" "lspci" "ip" "ethtool" "jq" "nginx" "hitch" "stunnel" "iperf3" "nuttcp" "httperf" "git" "hyperfine" "varnish"
11+
)
12+
13+
# httperf --server $OTHER_IP --port 8080 --num-calls 3000 --num-conns=1 --uri /hello
14+
15+
install_packages()
16+
{
17+
sudo dnf install "${packages[@]}"
18+
}
19+
20+
stop_services()
21+
{
22+
sudo cp /lib/systemd/system/rescue.target /lib/systemd/system/benchmark.target
23+
sudo systemctl add-wants benchmark.target sshd.service
24+
sudo systemctl isolate benchmark.target
25+
sudo systemctl list-units --state=running
26+
}
27+
28+
start_services()
29+
{
30+
sudo systemctl isolate multi-user.target
31+
}
32+
33+
set_cpu()
34+
{
35+
# Prevent frequency-scaling
36+
sudo cpupower frequency-set -g performance
37+
38+
# Prevent entering deep C-states to reduce latency and avoid menu governor bugs (there was one recently)
39+
# Although if we completely disable C1 then we are going to hit RAPL power limits immediately,
40+
# which results in a 30% perf hit on single-stream iperf
41+
# Disable just deeper C states, which avoids the big perf hit (although now we're exposed to menu governor bugs)
42+
sudo cpupower idle-set -D 2
43+
44+
# Disable Turbo Boost for more stable measurements
45+
# cpupower set --turbo-boost 0 doesn't work when the driver is intel_pstate instead of cpufreq
46+
sudo sh -c 'echo 1 >/sys/devices/system/cpu/intel_pstate/no_turbo'
47+
48+
# AMD
49+
sudo cpupower set -m passive
50+
sudo cpupower set --turbo-boost 0
51+
52+
sudo cpupower -c all set --perf-bias 0
53+
54+
# Bring system into a consistent state
55+
# TODO: switch and reboot between the two
56+
#sudo tuned-adm profile network-latency
57+
58+
sudo tuned-adm profile network-throughput
59+
60+
# we could use tuned-adm verify, but there is a bug where it tries to read non-existent hung_task_timeout_secs
61+
}
62+
63+
describe()
64+
{
65+
# Check all the settings we've changed above
66+
67+
# List running processes
68+
set -x
69+
sudo systemctl list-units --state=running
70+
LIBPROC_HIDE_KERNEL=1 ps -ejH
71+
72+
sudo cpupower -c all frequency-info
73+
sudo cpupower -c all idle-info
74+
sudo cpupower -c all info
75+
sudo cat /sys/devices/system/cpu/intel_pstate/no_turbo
76+
sudo tuned-adm profile_info
77+
sudo ss -neopatium
78+
79+
lscpu
80+
sudo turbostat true
81+
sudo lspci -k
82+
sudo ip a
83+
84+
for P in /sys/class/net/*; do
85+
IFACE=$(basename "${P}")
86+
sudo ethtool "${IFACE}"
87+
sudo ethtool -k "${IFACE}"
88+
done
89+
90+
sudo sos report --batch
91+
92+
set +x
93+
}
94+
95+
open_ports()
96+
{
97+
# iperf3, nuttcp
98+
for P in 5201 5000 5001 5101 5102 5103 5104; do
99+
sudo firewall-cmd --add-port "${P}/tcp"
100+
done
101+
}
102+
103+
iperf3_server()
104+
{
105+
iperf3 -s
106+
}
107+
108+
iperf3_client()
109+
{
110+
# TODO: autodetect IP
111+
iperf3 --json --logfile iperf3.json -c 10.70.58.43
112+
iperf3 --json --logfile iperf3_2.json -c 10.70.58.43 -P2
113+
iperf3 --json --logfile iperf3_4.json -c 10.70.58.43 -P4
114+
}
115+
116+

scripts/stunnel-perf/nginx.conf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error_log stderr error;
2+
pid /tmp/nginx.pid;
3+
daemon off;
4+
events {
5+
6+
}
7+
http {
8+
client_body_temp_path /tmp/nginx-client_body;
9+
proxy_temp_path /tmp/nginx-proxy;
10+
fastcgi_temp_path /tmp/nginx-fcgi;
11+
uwsgi_temp_path /tmp/nginx-uwsgi;
12+
scgi_temp_path /tmp/nginx-scgi;
13+
access_log off;
14+
tcp_nodelay on;
15+
server {
16+
gzip off;
17+
listen 8080 reuseport;
18+
location = /hello {
19+
default_type text/plain;
20+
return 200 "Hello";
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)