Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Unexpectedly poor cache performance

未关闭
#122 17 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
docker, go

调研方向

首先,使用提供的 ab 命令重现 cache-handler 配置,比较小图像在缓存和未缓存情况下的吞吐量。调查报告中描述的缓存指令和存储后端行为;完成的标准是找出变慢的原因,并验证性能改进,或明确记录一项限制。

由索引模型根据 Issue 内容生成。

描述

Caddy version: 2.9.1

The Problem:

When using the cache directive, the throughput of the given config block experiences a dramatic slowdown. On my system with 7950X testing using AB like so:

ab -k -t 60 -n 100000 -c 16 http://localhost:8080/image.png

Without caching: 85000-87000 requests per second
With caching: <3600 requests per second

image.png is a small (<20KiB) .png file of 185x250px dimensions.

Context:

For comparison, nginx in a similar scenario manages slower non-cached throughput (50-60k r/s), but dramatically faster cached throughput (15-17k r/s).

I tested versus nginx as my project presently uses its fork, Openresty (which is just nginx but with Lua scripting), to serve and cache static assets, and reverse proxy the main app. The expected production traffic consists of a high rate of requests against object storage backed image and thumbnail storage. It is crucial that this is cached (object storage egress costs money), and that the cache is performant enough to keep up with a high volume of requests.

If I were to switch to Caddy, the performance difference must not be too much worse.

The Config

{
    cache
}

:80 {
    route {
        cache # the "no cache" test was done with this line commented-out
        file_server {
            root /var/www
        }
    }
}

Caddy is built via Docker like so:

ARG CADDY_VERSION="2.9.1"

FROM caddy:$CADDY_VERSION-builder-alpine AS builder

RUN xcaddy build \
    --with github.com/caddyserver/cache-handler

FROM caddy:$CADDY_VERSION-alpine

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

EXPOSE 80

and ran like so

docker run --rm \
  -it \
  -v /home/luna/code/caddytest/config:/etc/caddy \
  -v /home/luna/code/caddytest/data:/data \
  -v /home/luna/code/caddytest/static:/var/www \
  -p 8080:80 \
  caddytest:latest

Needless to say, a very basic and barebones setup.

What I tried:

  • Using a different storage backend for the caching module (tried otter, etcd)
  • Putting it in a handle block
  • Using it without any route or handle blocks

This performance discrepancy compared to our current setup with nginx is completely unacceptable and prevents me from moving ahead with using Caddy in production (as my resources rely caching having a high throughput).

主要语言
Go
星标
396
派生
29
平均合并
32 分钟
30 天内合并 PR
1

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

caddyserver/cache-handler 的其他 Issue

查看 caddyserver/cache-handler 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。