← 返回日报
精读 预计 1 分钟

Caddy compatibility for zeroserve: 3x throughput and 70% lower latency

摘要

文章介绍 zeroserve 新增 Caddy 兼容模式,可接收 Caddyfile 后 JIT 编译为 eBPF,再编译成原生 x86_64/ARM64 机器码在 io_uring 事件循环中运行。给出基准测试数据:HTTPS 反向代理(2 线程,AMD Ryzen 7 3700X)中,zeroserve-clang 实现 38,948 req/s(p50 1.45ms,p99 3.91ms,RSS 30.9 MiB),zeroserve-tcc 实现 36,653 req/s(p50 1.67ms,p99 4.00ms,RSS 34.2 MiB),对比 caddy 的 12,529 req/s(p50 4.74ms,p99 13.11ms,RSS 67.4 MiB)和 nginx 的 37,424 req/s(p50 1.57ms,p99 4.24ms,RSS 25.7 MiB)。提供安装与使用示例:获取 io.su3.aws-sigv4.c 后,配置 Caddyfile 即可在 zeroserve 中调用自定义 eBPF 代码实现 S3 兼容桶的路径反向代理与 AWS SigV4 认证。

荐读理由

zeroserve eBPF JIT 编译 Caddyfile 成 x86/ARM 机器码,配合 io_uring 事件循环,2 线程下 p50 吞吐 38,948 req/s(caddy 12,529 req/s 的 3.1 倍)、p99 1.45ms(caddy 4.74ms 的 3.27 倍)、RSS 仅 30.9 MiB(caddy 67.4 MiB 的 45.8%),可以直接复用到你 AI 工程项目的 HTTPS 反代架构

原文

zeroserve is a high-performance HTTPS server that runs eBPF scripts in userspace (intro). Now it's got a Caddy-compat mode - when provided a Caddyfile, zeroserve JIT-compiles it to eBPF and then to native x86_64/ARM64 machine code, and runs it in an io_uringevent loop.

protocol server throughput p50 p99 peak RSS
https zeroserve-clang 38,948 req/s 1.45ms 3.91ms 30.9 MiB
https zeroserve-tcc 36,653 req/s 1.67ms 4.00ms 34.2 MiB
https caddy 12,529 req/s 4.74ms 13.11ms 67.4 MiB
https nginx 37,424 req/s 1.57ms 4.24ms 25.7 MiB

HTTPS reverse proxy, 2 threads, AMD Ryzen 7 3700X. Check CI for original run result.

Try it with your Caddyfile:

curl -fL -o zeroserve https://github.com/losfair/zeroserve/releases/download/v0.2.11/zeroserve-$(uname -m)-linux
chmod +x zeroserve
./zeroserve --caddy /etc/caddy/Caddyfile
curl http://127.0.0.1:8080

zeroserve runs turing-complete eBPF and you can call custom code from your Caddyfile. For example, to reverse-proxy a path to an S3-compatible bucket with AWS SigV4 auth, grab io.su3.aws-sigv4.c and then:

# zeroserve --plugin io.su3.aws-sigv4.c --caddy Caddyfile

example.com {
  route /s3/* {
    uri strip_prefix /s3
    rewrite * /my-bucket{uri}

    # Call the `sign_request` method in the eBPF middleware `io.su3.aws-sigv4.o`
    zeroserve_call io.su3.aws-sigv4 sign_request {
      access_key_id "minioadmin"
      secret_access_key "minioadmin"
    }

    reverse_proxy http://127.0.0.1:9000
  }
}
Hacker News · 90 赞 · 23 评 讨论 → 阅读原文 →

这条对你有帮助吗?