Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions frameworks/tokio/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target
.git
1 change: 1 addition & 0 deletions frameworks/tokio/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
168 changes: 168 additions & 0 deletions frameworks/tokio/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions frameworks/tokio/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "httparena-tokio"
version = "0.1.0"
edition = "2021"

[dependencies]
socket2 = { version = "0.5", features = ["all"] }
tokio = { version = "1", default-features = false, features = ["io-util", "net", "rt"] }

[profile.release]
codegen-units = 1
lto = "thin"
opt-level = 3
panic = "abort"
13 changes: 13 additions & 0 deletions frameworks/tokio/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM rust:1.95 AS build
WORKDIR /app
COPY Cargo.toml Cargo.lock ./
RUN mkdir src && echo "fn main() {}" > src/main.rs \
&& cargo build --release \
&& rm -rf src target/release/httparena-tokio target/release/deps/httparena_tokio*
COPY src ./src
RUN RUSTFLAGS="-C target-cpu=native" cargo build --release

FROM debian:bookworm-slim
COPY --from=build /app/target/release/httparena-tokio /server
EXPOSE 8080
CMD ["/server"]
23 changes: 23 additions & 0 deletions frameworks/tokio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# tokio

A minimal **HTTP/1.1** server on raw **tokio** — no HTTP framework. It serves the
H1-isolated profiles (`baseline`, `pipelined`, `limited-conn`) with a hand-rolled
request parser on a tokio `TcpStream`.

## Serving model
One `current_thread` tokio runtime per core, each binding `:8080` with
`SO_REUSEPORT` (kernel-sharded accept, no cross-core work-stealing), `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 `recv`s).

| Endpoint | Response |
|---|---|
| `GET/POST /baseline11?a=&b=` | `text/plain` — `a + b` (+ POST body as an integer) |
| `GET /pipeline` | `text/plain` — `ok` |

`PORT` overrides the listen port for local testing (defaults to 8080).
15 changes: 15 additions & 0 deletions frameworks/tokio/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"display_name": "tokio",
"language": "Rust",
"type": "engine",
"engine": "tokio",
"description": "Minimal HTTP/1.1 server on raw tokio — no HTTP framework. A hand-rolled request parser (request line, headers, Content-Length + chunked bodies, keep-alive, pipelining, fragmented reads) on a tokio TcpStream, with one current-thread runtime per core and SO_REUSEPORT.",
"repo": "https://github.com/tokio-rs/tokio",
"enabled": true,
"tests": [
"baseline",
"pipelined",
"limited-conn"
],
"maintainers": []
}
Loading