Skip to content

[Rust] Add tokio - HTTP/1.1#820

Merged
MDA2AV merged 2 commits into
mainfrom
add-tokio
Jun 6, 2026
Merged

[Rust] Add tokio - HTTP/1.1#820
MDA2AV merged 2 commits into
mainfrom
add-tokio

Conversation

@MDA2AV
Copy link
Copy Markdown
Owner

@MDA2AV MDA2AV commented Jun 6, 2026

Description

A minimal HTTP/1.1 server on raw tokio for the H1-isolated profiles (baseline, pipelined, limited-conn) — no HTTP framework. Added as an engine-tier entry.

Serving model

One current_thread tokio runtime per core, each with its own SO_REUSEPORT listener (socket2 + from_std), TCP_NODELAY per connection. Responses are batched per read so a pipelined burst flushes in one write.

Hand-rolled HTTP/1.1

Request line + headers, Content-Length and Transfer-Encoding: chunked bodies, keep-alive (multiple requests per connection), request pipelining, and fragmented-read reassembly (requests split across recvs).

Endpoint Response
GET/POST /baseline11?a=&b= text/plaina + b (+ POST body as an integer)
GET /pipeline text/plainok

Tests

Subscribes to baseline, pipelined, limited-conn. Verified against the full contract — GET55, Content-Length POST75, chunked POST75, /pipelineok, 16× pipelining, keep-alive, and fragmented reads — natively and via the Docker build.

Minimal HTTP/1.1 server on raw tokio for the H1-isolated profiles
(baseline, pipelined, limited-conn). No HTTP framework: a hand-rolled
request parser (request line, headers, Content-Length + chunked bodies,
keep-alive, pipelining, fragmented-read reassembly) on a tokio TcpStream,
one current-thread runtime per core with SO_REUSEPORT.

Endpoints: /baseline11?a=&b= -> a+b(+body) text/plain; /pipeline -> ok.
Validated against the baseline/pipelined contract (sum, Content-Length and
chunked bodies, keep-alive, 16x pipelining, fragmented reads) natively and
via the Docker build.
@MDA2AV
Copy link
Copy Markdown
Owner Author

MDA2AV commented Jun 6, 2026

/benchmark -f tokio --save

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 6, 2026

👋 /benchmark request received. A collaborator will review and approve the run.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 6, 2026

Benchmark Results

Framework: tokio | Test: all tests

Test Conn RPS CPU Mem Δ RPS Δ Mem
baseline 512 4,269,664 6289.3% 43MiB NEW NEW
baseline 4096 4,187,085 6417.9% 187MiB NEW NEW
pipelined 512 54,824,854 6385.0% 46MiB NEW NEW
pipelined 4096 54,755,795 6057.7% 164MiB NEW NEW
limited-conn 512 2,563,668 5380.0% 106MiB NEW NEW
limited-conn 4096 2,721,455 5727.1% 426MiB NEW NEW
Full log
  Pipeline:  1
  Req/conn:  10
  Templates: 3
  Expected:  200
  Duration:  5s


  Thread Stats   Avg      p50      p90      p99    p99.9
    Latency    185us    160us    314us    638us   1.46ms

  12818345 requests in 5.00s, 12818344 responses
  Throughput: 2.56M req/s
  Bandwidth:  161.29MB/s
  Status codes: 2xx=12818344, 3xx=0, 4xx=0, 5xx=0
  Latency samples: 12818295 / 12818344 responses (100.0%)
  Reconnects: 1281825
  Per-template: 4272801,4272732,4272762
  Per-template-ok: 4272801,4272732,4272762
[info] CPU 5380.0% | Mem 106MiB

[run 2/3]
gcannon v0.5.3
  Target:    localhost:8080/
  Threads:   64
  Conns:     512 (8/thread)
  Pipeline:  1
  Req/conn:  10
  Templates: 3
  Expected:  200
  Duration:  5s


  Thread Stats   Avg      p50      p90      p99    p99.9
    Latency    185us    161us    313us    630us   1.49ms

  12785092 requests in 5.00s, 12785083 responses
  Throughput: 2.56M req/s
  Bandwidth:  160.89MB/s
  Status codes: 2xx=12785083, 3xx=0, 4xx=0, 5xx=0
  Latency samples: 12785035 / 12785083 responses (100.0%)
  Reconnects: 1278489
  Per-template: 4261607,4261719,4261709
  Per-template-ok: 4261607,4261719,4261709
[info] CPU 5490.1% | Mem 107MiB

[run 3/3]
gcannon v0.5.3
  Target:    localhost:8080/
  Threads:   64
  Conns:     512 (8/thread)
  Pipeline:  1
  Req/conn:  10
  Templates: 3
  Expected:  200
  Duration:  5s


  Thread Stats   Avg      p50      p90      p99    p99.9
    Latency    185us    161us    314us    629us   1.50ms

  12769271 requests in 5.00s, 12769273 responses
  Throughput: 2.55M req/s
  Bandwidth:  160.66MB/s
  Status codes: 2xx=12769273, 3xx=0, 4xx=0, 5xx=0
  Latency samples: 12769226 / 12769273 responses (100.0%)
  Reconnects: 1276921
  Per-template: 4256405,4256491,4256330
  Per-template-ok: 4256405,4256490,4256330
[info] CPU 5357.4% | Mem 107MiB

=== Best: 2563668 req/s (CPU: 5380.0%, Mem: 106MiB) ===
[info] input BW: 198.04MB/s (avg template: 81 bytes)
[info] saved results/limited-conn/512/tokio.json
httparena-bench-tokio
httparena-bench-tokio

==============================================
=== tokio / limited-conn / 4096c (tool=gcannon) ===
==============================================
[info] waiting for server...
[info] server ready

[run 1/3]
gcannon v0.5.3
  Target:    localhost:8080/
  Threads:   64
  Conns:     4096 (64/thread)
  Pipeline:  1
  Req/conn:  10
  Templates: 3
  Expected:  200
  Duration:  5s


  Thread Stats   Avg      p50      p90      p99    p99.9
    Latency   1.41ms   1.28ms   1.71ms   2.60ms   5.67ms

  13403095 requests in 5.00s, 13403174 responses
  Throughput: 2.68M req/s
  Bandwidth:  168.66MB/s
  Status codes: 2xx=13403174, 3xx=0, 4xx=0, 5xx=0
  Latency samples: 13403174 / 13403174 responses (100.0%)
  Reconnects: 1338627
  Per-template: 4467697,4467683,4467794
  Per-template-ok: 4467697,4467683,4467794
[info] CPU 5398.3% | Mem 425MiB

[run 2/3]
gcannon v0.5.3
  Target:    localhost:8080/
  Threads:   64
  Conns:     4096 (64/thread)
  Pipeline:  1
  Req/conn:  10
  Templates: 3
  Expected:  200
  Duration:  5s


  Thread Stats   Avg      p50      p90      p99    p99.9
    Latency   1.38ms   1.29ms   1.70ms   2.36ms   4.02ms

  13607518 requests in 5.00s, 13607275 responses
  Throughput: 2.72M req/s
  Bandwidth:  171.22MB/s
  Status codes: 2xx=13607276, 3xx=0, 4xx=0, 5xx=0
  Latency samples: 13607163 / 13607275 responses (100.0%)
  Reconnects: 1360469
  Per-template: 4536008,4535684,4535471
  Per-template-ok: 4536008,4535684,4535471

  WARNING: 18446744073709551615/13607275 responses (135565306600399.8%) had unexpected status (expected 2xx)
[info] CPU 5727.1% | Mem 426MiB

[run 3/3]
gcannon v0.5.3
  Target:    localhost:8080/
  Threads:   64
  Conns:     4096 (64/thread)
  Pipeline:  1
  Req/conn:  10
  Templates: 3
  Expected:  200
  Duration:  5s


  Thread Stats   Avg      p50      p90      p99    p99.9
    Latency   1.38ms   1.30ms   1.71ms   2.33ms   3.85ms

  13579926 requests in 5.00s, 13579907 responses
  Throughput: 2.71M req/s
  Bandwidth:  170.88MB/s
  Status codes: 2xx=13579907, 3xx=0, 4xx=0, 5xx=0
  Latency samples: 13579843 / 13579907 responses (100.0%)
  Reconnects: 1357757
  Per-template: 4526888,4526243,4526711
  Per-template-ok: 4526888,4526243,4526711
[info] CPU 5564.5% | Mem 431MiB

=== Best: 2721455 req/s (CPU: 5727.1%, Mem: 426MiB) ===
[info] input BW: 210.23MB/s (avg template: 81 bytes)
[info] saved results/limited-conn/4096/tokio.json
httparena-bench-tokio
httparena-bench-tokio
[info] skip: tokio does not subscribe to json
[info] skip: tokio does not subscribe to json-comp
[info] skip: tokio does not subscribe to json-tls
[info] skip: tokio does not subscribe to upload
[info] skip: tokio does not subscribe to api-4
[info] skip: tokio does not subscribe to api-16
[info] skip: tokio does not subscribe to static
[info] skip: tokio does not subscribe to async-db
[info] skip: tokio does not subscribe to crud
[info] skip: tokio does not subscribe to fortunes
[info] skip: tokio does not subscribe to baseline-h2
[info] skip: tokio does not subscribe to static-h2
[info] skip: tokio does not subscribe to baseline-h2c
[info] skip: tokio does not subscribe to json-h2c
[info] skip: tokio does not subscribe to baseline-h3
[info] skip: tokio does not subscribe to static-h3
[info] skip: tokio does not subscribe to gateway-64
[info] skip: tokio does not subscribe to gateway-h3
[info] skip: tokio does not subscribe to production-stack
[info] skip: tokio does not subscribe to unary-grpc
[info] skip: tokio does not subscribe to unary-grpc-tls
[info] skip: tokio does not subscribe to stream-grpc
[info] skip: tokio does not subscribe to stream-grpc-tls
[info] skip: tokio does not subscribe to echo-ws
[info] skip: tokio does not subscribe to echo-ws-pipeline
[info] rebuilding site/data/*.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/frameworks.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/baseline-4096.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/baseline-512.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/limited-conn-4096.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/limited-conn-512.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/pipelined-4096.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/pipelined-512.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/current.json
[info] done
[info] restoring loopback MTU to 65536

@MDA2AV MDA2AV merged commit 2f52740 into main Jun 6, 2026
@MDA2AV MDA2AV deleted the add-tokio branch June 7, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant