Skip to content

Commit de95377

Browse files
authored
Merge pull request #745 from justinGrosvenor/swerver-alpha3
swerver: update to v0.1.0-alpha.10 — rate-limit headers, upload fixes, H2 improvements
2 parents 4ae72c4 + 07998cf commit de95377

45 files changed

Lines changed: 6740 additions & 2323 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

frameworks/swerver/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM debian:trixie AS build
22

33
RUN apt-get update && apt-get install -y --no-install-recommends \
4-
ca-certificates curl xz-utils git libssl-dev dpkg-dev pkg-config python3 \
4+
ca-certificates curl xz-utils git libssl-dev zlib1g-dev dpkg-dev pkg-config python3 \
55
&& rm -rf /var/lib/apt/lists/*
66

77
# Install Zig 0.16.0 stable
@@ -22,7 +22,7 @@ RUN set -eux; \
2222

2323
# Clone swerver library
2424
WORKDIR /src
25-
RUN git clone --depth 1 --branch v0.1.0-alpha.6 \
25+
RUN git clone --depth 1 --branch v0.1.0-alpha.10 \
2626
https://github.com/justinGrosvenor/swerver.git .
2727

2828
# Symlink OpenSSL for Zig's linker
@@ -46,9 +46,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
4646
COPY --from=build /src/httparena/zig-out/bin/swerver-httparena /usr/local/bin/swerver
4747
COPY config-h1.json /etc/swerver/config-h1.json
4848
COPY config-tls.json /etc/swerver/config-tls.json
49+
COPY config-tls-h1.json /etc/swerver/config-tls-h1.json
4950
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
5051
RUN chmod +x /usr/local/bin/entrypoint.sh
5152

52-
EXPOSE 8080 8443/tcp 8443/udp
53+
EXPOSE 8080 8081 8443/tcp 8443/udp
5354

5455
CMD ["/usr/local/bin/entrypoint.sh"]

frameworks/swerver/build.zig.zon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.{
22
.name = .swerver_httparena,
3-
.version = "0.1.0-alpha.6",
3+
.version = "0.1.0-alpha.10",
44
.fingerprint = 0xd44040f91e2c7045,
55
.minimum_zig_version = "0.16.0",
66
.paths = .{

frameworks/swerver/config-h1.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
},
1313
"buffer_pool": {
1414
"buffer_size": 65536,
15-
"buffer_count": 1024,
16-
"body_buffer_size": 22020096,
17-
"body_buffer_count": 2
15+
"buffer_count": 1024
1816
},
1917
"http2": {
2018
"max_streams": 256,
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"server": {
3+
"address": "0.0.0.0",
4+
"port": 8081,
5+
"max_connections": 512,
6+
"static_root": "/data/static",
7+
"workers": 0,
8+
"disable_middleware": true
9+
},
10+
"buffer_pool": {
11+
"buffer_size": 65536,
12+
"buffer_count": 1024
13+
},
14+
"tls": {
15+
"cert_path": "/certs/server.crt",
16+
"key_path": "/certs/server.key"
17+
},
18+
"http2": {
19+
"max_streams": 256,
20+
"initial_window_size": 1048576
21+
}
22+
}

frameworks/swerver/entrypoint.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@ H1_PID=$!
77
/usr/local/bin/swerver --config /etc/swerver/config-tls.json &
88
TLS_PID=$!
99

10+
/usr/local/bin/swerver --config /etc/swerver/config-tls-h1.json &
11+
TLS_H1_PID=$!
12+
1013
shutdown() {
11-
kill "$H1_PID" "$TLS_PID" 2>/dev/null || true
14+
kill "$H1_PID" "$TLS_PID" "$TLS_H1_PID" 2>/dev/null || true
1215
wait "$H1_PID" 2>/dev/null || true
1316
wait "$TLS_PID" 2>/dev/null || true
17+
wait "$TLS_H1_PID" 2>/dev/null || true
1418
exit 0
1519
}
1620
trap shutdown TERM INT
1721

18-
wait -n "$H1_PID" "$TLS_PID"
22+
wait -n "$H1_PID" "$TLS_PID" "$TLS_H1_PID"
1923
shutdown
2024
exit 1

frameworks/swerver/main.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ pub fn main(init: std.process.Init) !void {
271271
try app_router.get("/baseline2", handleBaseline);
272272
try app_router.post("/baseline2", handleBaseline);
273273
try app_router.get("/json/:count", handleJson);
274-
try app_router.post("/upload", handleUpload);
274+
try app_router.postDiscard("/upload", handleUpload);
275275

276276
if (cfg.workers != 1) {
277277
var master = try swerver.Master.init(allocator, cfg, app_router, null);

frameworks/swerver/meta.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
"pipelined",
1212
"limited-conn",
1313
"json",
14+
"json-tls",
15+
"upload",
1416
"static",
1517
"baseline-h2",
1618
"static-h2",

site/data/baseline-4096.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,19 +1129,19 @@
11291129
{
11301130
"framework": "swerver",
11311131
"language": "Zig",
1132-
"rps": 3722628,
1133-
"avg_latency": "1.10ms",
1134-
"p99_latency": "2.21ms",
1135-
"cpu": "6341.1%",
1136-
"memory": "9.7GiB",
1132+
"rps": 3664110,
1133+
"avg_latency": "1.12ms",
1134+
"p99_latency": "2.16ms",
1135+
"cpu": "6396.6%",
1136+
"memory": "1.8GiB",
11371137
"connections": 4096,
11381138
"threads": 64,
11391139
"duration": "5s",
11401140
"pipeline": 1,
1141-
"bandwidth": "365.57MB/s",
1142-
"input_bw": "287.56MB/s",
1141+
"bandwidth": "359.81MB/s",
1142+
"input_bw": "283.04MB/s",
11431143
"reconnects": 0,
1144-
"status_2xx": 18613142,
1144+
"status_2xx": 18320551,
11451145
"status_3xx": 0,
11461146
"status_4xx": 0,
11471147
"status_5xx": 0

site/data/baseline-512.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,19 +1129,19 @@
11291129
{
11301130
"framework": "swerver",
11311131
"language": "Zig",
1132-
"rps": 3543108,
1133-
"avg_latency": "143us",
1134-
"p99_latency": "376us",
1135-
"cpu": "6505.9%",
1136-
"memory": "9.7GiB",
1132+
"rps": 3528277,
1133+
"avg_latency": "144us",
1134+
"p99_latency": "368us",
1135+
"cpu": "6407.9%",
1136+
"memory": "1.8GiB",
11371137
"connections": 512,
11381138
"threads": 64,
11391139
"duration": "5s",
11401140
"pipeline": 1,
1141-
"bandwidth": "347.93MB/s",
1142-
"input_bw": "273.70MB/s",
1141+
"bandwidth": "346.49MB/s",
1142+
"input_bw": "272.55MB/s",
11431143
"reconnects": 0,
1144-
"status_2xx": 17715540,
1144+
"status_2xx": 17641387,
11451145
"status_3xx": 0,
11461146
"status_4xx": 0,
11471147
"status_5xx": 0

site/data/baseline-h2-1024.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -375,19 +375,18 @@
375375
{
376376
"framework": "swerver",
377377
"language": "Zig",
378-
"rps": 1472297,
379-
"avg_latency": "64.62ms",
380-
"p99_latency": "64.62ms",
381-
"cpu": "6199.2%",
382-
"memory": "1.7GiB",
378+
"rps": 2267290,
379+
"avg_latency": "42.15ms",
380+
"p99_latency": "42.15ms",
381+
"cpu": "6354.1%",
382+
"memory": "2.4GiB",
383383
"connections": 1024,
384384
"threads": 64,
385385
"duration": "5s",
386386
"pipeline": 1,
387-
"bandwidth": "155.87MB/s",
388-
"input_bw": "",
387+
"bandwidth": "242.90MB/s",
389388
"reconnects": 0,
390-
"status_2xx": 7361507,
389+
"status_2xx": 11472492,
391390
"status_3xx": 0,
392391
"status_4xx": 0,
393392
"status_5xx": 0

0 commit comments

Comments
 (0)