Skip to content

Commit 2fc36b4

Browse files
authored
chore: benchmarks [skip ci] (#155)
- lighttpd 1.4.67 (default config) - nginx 1.22.0 (default config + worker_processes=4) - sws 2.13.1 (default config) - apache 2.4.54 (default config) - caddy 2.6.1 (default config) - binserve 0.2.0 (default config + fast_mem_cache=false, enable_hot_reload=false, enable_logging=false, enable_directory_listing=false)
1 parent 697aa95 commit 2fc36b4

File tree

7 files changed

+123
-1
lines changed

7 files changed

+123
-1
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
**/*.out*
1919
**/*.perf*
2020
**/*empty*
21+
**/*.json
22+
**/*.csv
2123
release
2224
.vscode
2325
TODO
@@ -28,3 +30,4 @@ docs/*/**.html
2830
!sample.env
2931
!/docs
3032
!/tests/fixtures/**/*
33+
!benchmark/sws_benchmarks*.csv

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,17 @@ promote:
282282
.PHONY: promote
283283

284284
loadtest:
285+
@vegeta --version
285286
@echo "GET http://localhost:8787" | \
286-
vegeta -cpus=12 attack -workers=10 -duration=60s -connections=10000 -rate=200 -http2=false > results.bin
287+
vegeta -cpus=12 attack -workers=12 -connections=500 -rate=6500/s -duration=10s -http2=false > results.bin
287288
@cat results.bin | vegeta report -type='hist[0,2ms,4ms,6ms]'
288289
@cat results.bin | vegeta plot > plot.html
289290
.PHONY: loadtest
290291

292+
wrk:
293+
@wrk -c 500 -t 12 -d 10s --latency -s benchmark/wrk_collector.lua $(WRK_URL)
294+
.PHONY: wrk
295+
291296
man:
292297
@asciidoctor --doctype=manpage --backend=manpage docs/man/static-web-server.1.rst
293298
.PHONY: man

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ For more details about the API, usage and examples please have a look at [The Do
7474
- [Release Binaries](https://github.com/joseluisq/static-web-server/releases)
7575
- [Platforms/Architectures Supported](https://sws.joseluisq.net/platforms-architectures/)
7676

77+
## Benchmarks
78+
79+
<img title="SWS - Benchmarks 2022" src="benchmark/sws_benchmarks.png" width="860">
80+
81+
See more details on [benchmark/BENCHMARKS.md](benchmark/BENCHMARKS.md)
82+
7783
## Notes
7884

7985
- If you're looking for `v1` please go to [1.x](https://github.com/joseluisq/static-web-server/tree/1.x) branch.

benchmark/BENCHMARKS.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SWS - Benchmarks 2022
2+
3+
> A benchmark suite which measures the requests per second and latency in average for several web servers.
4+
5+
<img title="SWS - Benchmarks 2022" src="data/sws_benchmarks.png" width="860">
6+
7+
## How to use
8+
9+
Change `WRK_URL` with the corresponding server URL to export the wrk metrics.
10+
11+
```sh
12+
WRK_URL="http://localhost" make wrk
13+
```
14+
15+
## System
16+
17+
- **OS:** Arch Linux
18+
- **Kernel:** 5.19.13-arch1-1 (64 bits)
19+
- **Processor:** 4 × Intel® Core™ i7-6500U
20+
- **RAM:** 8 GiB
21+
22+
## Data
23+
24+
For data used see [data](./data/) directory for more details.

benchmark/sws_benchmarks.csv

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
server,requests,duration_ms,requests_per_sec,bytes,bytes_transfer_per_sec,connect_errors,read_errors,write_errors,http_errors,timeouts,latency_min,latency_max,latency_mean_ms,latency_stdev
2+
lighttpd 1.4.67,484277,"10,088.91 ms",48000.91,"1,094.53 mb",10848848.82,0,0,0,0,151,29,482359,7.36 ms,6710.11
3+
nginx 1.22.0,439964,"10,096.09 ms",43577.64,"3,752.89 mb",37171731.17,0,0,0,0,0,163,286376,11.44 ms,7715.38
4+
sws 2.13.1,413213,"10,076.99 ms",41005.59,"2,958.61 mb",29360002.27,0,0,0,0,0,74,94650,12.85 ms,9118.04
5+
apache 2.4.54,266118,"10,098.43 ms",26352.4,630.98 mb,6248330.38,0,5411,0,0,0,65,808201,89.82 ms,132231.85
6+
caddy 2.6.1,191447,"10,079.89 ms",18992.97,"3,011.53 mb",29876599.7,0,0,0,0,0,99,418180,38.44 ms,46037.13
7+
binserve 0.2.0,95837,"10,100.44 ms",9488.4,"1,632.43 mb",16161969.78,0,0,0,0,0,100,142686,51.15 ms,16476.27

benchmark/sws_benchmarks.png

26 KB
Loading

benchmark/wrk_collector.lua

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
-- Script that runs at wrk's "done" stage collecting the stats in JSON and CSV formats.
2+
-- https://github.com/wg/wrk/blob/master/SCRIPTING
3+
done = function(summary, latency, requests)
4+
local json = string.format("{\n")
5+
json = json .. string.format('\t"requests": %d,\n', summary.requests)
6+
json = json .. string.format('\t"duration_ms": %0.2f,\n', summary.duration / 1000)
7+
json = json .. string.format('\t"requests_per_sec": %0.2f,\n', (summary.requests / summary.duration) * 1e6)
8+
json = json .. string.format('\t"bytes": %d,\n', summary.bytes)
9+
json = json .. string.format('\t"bytes_transfer_per_sec": %0.2f,\n', (summary.bytes / summary.duration) * 1e6)
10+
json = json .. string.format('\t"connect_errors": %d,\n', summary.errors.connect)
11+
json = json .. string.format('\t"read_errors": %d,\n', summary.errors.read)
12+
json = json .. string.format('\t"write_errors": %d,\n', summary.errors.write)
13+
json = json .. string.format('\t"http_errors": %d,\n', summary.errors.status)
14+
json = json .. string.format('\t"timeouts": %d,\n', summary.errors.timeout)
15+
json = json .. string.format('\t"latency_min": %0.2f,\n', latency.min)
16+
json = json .. string.format('\t"latency_max": %0.2f,\n', latency.max)
17+
json = json .. string.format('\t"latency_mean_ms": %0.2f,\n', latency.mean / 1000)
18+
json = json .. string.format('\t"latency_stdev": %0.2f,\n', latency.stdev)
19+
20+
json = json .. string.format('\t"latency_distribution": [\n')
21+
for _, pair in pairs({50, 75, 90, 99}) do
22+
json = json .. string.format("\t\t{\n")
23+
24+
local percent = latency:percentile(pair)
25+
json = json .. string.format('\t\t\t"percentile": %g,\n\t\t\t"latency_ms": %0.2f\n', pair, percent / 1000)
26+
json = json .. string.format("\t\t}%s\n", pair > 90 and "" or ",")
27+
end
28+
29+
json = json .. string.format("\t]\n}\n")
30+
31+
local file, err = io.open("benchmark/wrk_results.json", "w")
32+
if file then
33+
file:write(json)
34+
file:close()
35+
else
36+
print("error saving json results file:", err)
37+
end
38+
39+
local csv = ''
40+
csv = csv .. string.format('requests,')
41+
csv = csv .. string.format('duration_ms,')
42+
csv = csv .. string.format('requests_per_sec,')
43+
csv = csv .. string.format('bytes,')
44+
csv = csv .. string.format('bytes_transfer_per_sec,')
45+
csv = csv .. string.format('connect_errors,')
46+
csv = csv .. string.format('read_errors,')
47+
csv = csv .. string.format('write_errors,')
48+
csv = csv .. string.format('http_errors,')
49+
csv = csv .. string.format('timeouts,')
50+
csv = csv .. string.format('latency_min,')
51+
csv = csv .. string.format('latency_max,')
52+
csv = csv .. string.format('latency_mean_ms,')
53+
csv = csv .. string.format('latency_stdev\n')
54+
55+
csv = csv .. string.format('%d,', summary.requests)
56+
csv = csv .. string.format('%0.2f,', summary.duration / 1000)
57+
csv = csv .. string.format('%0.2f,', (summary.requests / summary.duration) * 1e6)
58+
csv = csv .. string.format('%d,', summary.bytes)
59+
csv = csv .. string.format('%0.2f,', (summary.bytes / summary.duration) * 1e6)
60+
csv = csv .. string.format('%d,', summary.errors.connect)
61+
csv = csv .. string.format('%d,', summary.errors.read)
62+
csv = csv .. string.format('%d,', summary.errors.write)
63+
csv = csv .. string.format('%d,', summary.errors.status)
64+
csv = csv .. string.format('%d,', summary.errors.timeout)
65+
csv = csv .. string.format('%0.2f,', latency.min)
66+
csv = csv .. string.format('%0.2f,', latency.max)
67+
csv = csv .. string.format('%0.2f,', latency.mean / 1000)
68+
csv = csv .. string.format('%0.2f\n', latency.stdev)
69+
70+
local file, err = io.open("benchmark/wrk_results.csv", "w")
71+
if file then
72+
file:write(csv)
73+
file:close()
74+
else
75+
print("error saving csv results file:", err)
76+
end
77+
end

0 commit comments

Comments
 (0)