Skip to content
Open
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
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# vanilla
# vanilla-epoll

[vanilla](https://github.com/enghitalo/vanilla) is a minimalist, high-performance
HTTP server written in [V](https://vlang.io) — multi-threaded, non-blocking
epoll I/O, lock-free, copy-free, with `SO_REUSEPORT`.
HTTP server written in [V](https://vlang.io) — multi-threaded, non-blocking,
lock-free, copy-free, with `SO_REUSEPORT`. This entry runs the **epoll** I/O
backend (`io_multiplexing: .epoll`); see `vanilla-io_uring` for the io_uring
backend.

## Implemented profiles

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,8 @@ fn main() {
limits: http_server.Limits{
max_request_bytes: 32 * 1024 * 1024 // accept the 20 MiB upload bodies
}
request_handler: fn [mut sh] (req_buffer []u8, fd int) ![]u8 {
return handle(req_buffer, fd, mut sh)
request_handler: fn [mut sh] (req_buffer []u8, fd int, mut out []u8) ! {
out << handle(req_buffer, fd, mut sh)!
}
})!
server.run()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"display_name": "vanilla",
"display_name": "vanilla-epoll",
"language": "V",
"type": "engine",
"engine": "epoll",
Expand Down
2 changes: 2 additions & 0 deletions frameworks/vanilla-io_uring/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
server
*.so
28 changes: 28 additions & 0 deletions frameworks/vanilla-io_uring/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM debian:stable-slim AS build

RUN apt-get -qq update && \
apt-get -qy install --no-install-recommends \
ca-certificates curl unzip build-essential git libpq-dev liburing-dev && \
rm -rf /var/lib/apt/lists/*

# Pinned, reproducible V 0.5.1 (prebuilt release binary — no source build, and it
# avoids the `git checkout <tag> && make` vc-mismatch problem).
RUN curl -fsSL https://github.com/vlang/v/releases/download/0.5.1/v_linux.zip -o /tmp/v.zip && \
unzip -q /tmp/v.zip -d /opt && rm /tmp/v.zip && \
ln -s /opt/v/v /usr/local/bin/v

# Install the vanilla HTTP server as the `vanilla` module (import vanilla.http_server).
RUN git clone --depth 1 https://github.com/enghitalo/vanilla /root/.vmodules/vanilla

WORKDIR /app
COPY . .
RUN v -prod . -o server

FROM debian:stable-slim
RUN apt-get -qq update && \
apt-get -qy install --no-install-recommends libpq5 liburing2 && \
rm -rf /var/lib/apt/lists/*
COPY --from=build /app/server /server

EXPOSE 8080
CMD ["/server"]
38 changes: 38 additions & 0 deletions frameworks/vanilla-io_uring/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# vanilla-io_uring

[vanilla](https://github.com/enghitalo/vanilla) is a minimalist, high-performance
HTTP server written in [V](https://vlang.io) — multi-threaded, non-blocking,
lock-free, copy-free, with `SO_REUSEPORT`. This entry runs the **io_uring** I/O
backend (`io_multiplexing: .io_uring`); see `vanilla-epoll` for the epoll
backend. The harness runs it with `--security-opt seccomp=unconfined` and
`--ulimit memlock=-1:-1` (keyed off `engine: io_uring` in `meta.json`).

## Implemented profiles

| Profile | Endpoint | Notes |
|---|---|---|
| `baseline` | `GET/POST /baseline11` | `a + b` (+ body on POST); handles chunked + TCP-fragmented requests |
| `pipelined` | `GET /pipeline` | returns `ok` |
| `upload` | `POST /upload` | returns body byte count (up to 20+ MiB via `max_request_bytes`) |
| `limited-conn` | `GET /baseline11` | short-lived connections |
| `json` | `GET /json/{count}?m=M` | single-allocation response, precomputed item prefixes |
| `json-comp` | `GET /json/...` + `Accept-Encoding` | gzip-compressed response |
| `static` | `GET /static/<file>` | assets preloaded into memory, MIME by extension, 404 on miss |
| `async-db` | `GET /async-db?min&max&limit` | `db.pg` ConnectionPool |
| `crud` | `GET/POST/PUT /crud/items[/id]` | list + read + create + update; in-memory cache-aside (`X-Cache` MISS/HIT, invalidated on update — no Redis) |
| `fortunes` | `GET /fortunes` | DB rows + runtime row, HTML-escaped |
| `api-4`, `api-16` | mixed baseline + json + async-db | |

## Stack

* [V](https://vlang.io) 0.5.1 (pinned prebuilt release)
* [vanilla](https://github.com/enghitalo/vanilla) — raw io_uring HTTP server
* `db.pg`, `json`, `compress.gzip` (stdlib)

## Environment

* `DATABASE_URL`, `DATABASE_MAX_CONN` — Postgres connection + pool size
* `DATASET_PATH` (default `/data/dataset.json`), `STATIC_DIR` (default `/data/static`)

> HTTP/2, HTTP/3 and gRPC profiles need protocol support vanilla doesn't have
> yet — tracked in [enghitalo/vanilla#18](https://github.com/enghitalo/vanilla/issues/18).
Loading