---
title: "Caddy vs. NGINX vs. Traefik: Docker Production Benchmark & Config Guide"
description: "Hands-on Docker benchmark comparing Caddy 2, NGINX, and Traefik v3 under HTTPS, cold TLS handshakes, memory load, and zero-downtime SSE reloads."
author: Aleksei Aleinikov
date: 2026-12-06
lang: en
tags: [caddy-vs-nginx, traefik-vs-caddy, traefik-vs-nginx, caddy-reverse-proxy, devops, docker, kubernetes]
canonical: https://www.alekseialeinikov.com/en/blog/topics/devops/caddy-vs-nginx-vs-traefik-docker-production
source: alekseialeinikov.com
---

# Caddy vs. NGINX vs. Traefik: Docker Production Benchmark & Config Guide

Every containerized production stack hits the same crossroads right after you get your app and database running safely: **what sits on ports 80 and 443 in front of them?**

In production, reverse proxy outages rarely happen because a proxy "wasn't fast enough." They happen at **3:00 a.m.** when a Certbot cron hook silently fails to reload NGINX, when an unbuffered `nginx -s reload` kills long-lived Server-Sent Events, or when someone copies a 90-line Traefik Docker label block and breaks routing across three containers.

> [!KEY]
> **The short verdict.** **NGINX** is still the raw throughput king (**17,743 req/s**), **Caddy** is the operational sweet spot (**13,358 req/s**, **35.7 MiB** active RAM, **13-line** config with built-in auto-HTTPS), and **Traefik** wins when containers spin up and down dynamically via Docker labels — at the cost of **4.5× more RAM under load**.

![Caddy vs NGINX vs Traefik: Docker TLS, k6 Throughput, RAM & Zero-Downtime Reloads](https://media.alekseialeinikov.com/devops/c8a4f21d9e07/cover-1200.5725f166e3acd853.webp)

If you already locked down your database layer (see [PostgreSQL in Docker for Production](https://www.alekseialeinikov.com/en/blog/topics/data/postgresql-in-docker-production)), choosing the right **Docker reverse proxy** is the next structural decision. Instead of repeating decade-old "NGINX uses 10 MB and is 30% faster" folklore, we built a reproducible container benchmark and measured all three head-to-head.

## Architecture: Three Proxies, Three Complexity Budgets

Before looking at requests per second, look at what each proxy actually asks you to maintain for the exact same production baseline (**HTTPS + gzip/zstd + security headers + upstream keep-alive**):

![Caddy vs NGINX vs Traefik operational architecture in Docker: Caddyfile auto-HTTPS vs NGINX external Certbot vs Traefik dynamic providers](https://media.alekseialeinikov.com/devops/c8a4f21d9e07/architecture-1200.c2974d152476a0df.webp "Caddy folds TLS automation into a 13-line Caddyfile, NGINX separates TLS renewal into external Certbot tooling, and Traefik splits static entrypoints from dynamic labels or files.")

| Dimension | Caddy 2 (`2.11.9`) | NGINX (`1.31.10`) | Traefik v3 (`3.8.0`) |
|---|---|---|---|
| **Core Engine** | Go (`net/http` + `crypto/tls`) | C event loop (`epoll` + OpenSSL) | Go (`net/http` + `crypto/tls`) |
| **Config Footprint (Equivalent Setup)** | **13 lines** (`Caddyfile`) | **39 lines** (`nginx.conf`) | **38 lines** (`traefik.yml` + `dynamic.yml`) |
| **Automatic HTTPS (Let's Encrypt)** | **Built-in & default** (ACME + OCSP) | Manual (Certbot sidecar + cron + reload) | **Built-in** (HTTP-01 / TLS-ALPN-01 / DNS-01) |
| **HTTP/3 (QUIC)** | **Enabled by default** | Manual `quic` listener + UDP config | Opt-in `http3` entrypoint flag |
| **Dynamic Docker Discovery** | Manual `Caddyfile` (or `caddy-docker-proxy` plugin) | Requires external `nginx-proxy` / `docker-gen` | **Native** (`providers.docker` labels) |
| **Config Reload Mechanism** | Atomic `caddy reload` via `:2019` Admin API | `nginx -s reload` (spawns new workers) | Automatic file/socket watcher (`watch: true`) |

Notice the trap in the **NGINX** column: those **39 lines** do *not* even include TLS certificate issuance or renewal. To match Caddy's automatic HTTPS, NGINX needs an extra Certbot container, a shared ACME challenge volume, and a reload trigger.

## Real Docker `k6` Benchmark: Throughput, Cold TLS & RAM

To eliminate host port-forwarding overhead and get clean numbers, all three proxies ran sequentially inside the same isolated Docker bridge network (`rp-bench-net`, `--cpus=2 --memory=512m`) in front of an identical Node.js 24 HTTP/SSE upstream (`--cpus=2 --memory=256m`), driven from inside the same network by **Grafana k6 v2.4.0** (see [Grafana k6 vs. Apache JMeter](https://www.alekseialeinikov.com/en/blog/topics/devops/grafana-k6-vs-apache-jmeter-load-testing) for why `k6` avoids generator bottlenecks).

> [!NOTE]
> **Reproducible benchmark repository.** Every `Caddyfile`, `nginx.conf`, `traefik.yml`, `k6` script, and the `run.sh` runner is published at [LF3551/reverse-proxy-benchmark](https://github.com/LF3551/reverse-proxy-benchmark). Run `./run.sh` on any Docker host to verify these numbers yourself.

![Caddy vs NGINX vs Traefik k6 benchmark results: warm HTTPS throughput, cold TLS p95 latency, container RAM under load, and zero-downtime reload](https://media.alekseialeinikov.com/devops/c8a4f21d9e07/benchmark-1200.56506e4e2bc0dfbe.webp "NGINX leads raw warm throughput (17,743 req/s), while Caddy uses the least active RAM (35.7 MiB) and avoids OpenSSL cold-TLS tail spikes.")

| Benchmark Metric (2 vCPU / 512 MiB Cap) | Caddy `2.11.9` | NGINX `1.31.10` | Traefik `3.8.0` |
|---|---|---|---|
| **Idle Container RAM (`docker stats`)** | **19.2 MiB** | 40.0 MiB | 22.3 MiB |
| **Active RAM Under 50-VU Load** | **35.7 MiB** | 50.6 MiB | **160.0 MiB** |
| **Warm HTTPS + gzip (50 VUs, 15s)** | 13,358 req/s | **17,743 req/s** | 14,646 req/s |
| **Warm Latency (`med` / `p95`)** | 3.41 ms / 7.02 ms | **1.17 ms / 3.09 ms** | 3.21 ms / 5.53 ms |
| **Cold TLS Handshakes (25 VUs, no reuse)** | 1,181 req/s | **1,681 req/s** | 1,196 req/s |
| **Cold TLS Latency (`med` / `p95`)** | 11.26 ms / 24.13 ms | 1.36 ms / **68.33 ms** | 10.78 ms / **23.44 ms** |
| **Zero-Downtime Reload (20 VUs + 5s SSE)** | **0 drops · 25/25 ticks** | **0 drops · 25/25 ticks** | **0 drops · 25/25 ticks** |

Three real-world findings jump straight out of those numbers:

1. **The "NGINX uses 10 MB RAM" myth breaks on modern Docker hosts.** Because `nginx:alpine` enables `worker_processes auto` by default, NGINX spawns one worker per visible CPU core. On a multi-core host, idle NGINX started at **40.0 MiB** — **2× higher than Caddy (19.2 MiB)** and **Traefik (22.3 MiB)**.
2. **Traefik's RAM jumps 7× under real traffic.** At idle, Traefik looks lean (**22.3 MiB**). Under 50 concurrent virtual users, its active footprint jumped to **160.0 MiB** (**4.5× Caddy's 35.7 MiB**). On a 4 GB cloud VM that is irrelevant; on a 512 MB–1 GB micro-VPS sharing space with Postgres and an app container, it matters.
3. **Cold TLS tail latency favors Go under burst.** NGINX pushed the highest average cold-TLS rate (**1,681 req/s**), yet its `p95` tail spiked to **68.33 ms** when 25 VUs hammered fresh RSA-2048 handshakes simultaneously. Both Go proxies (**Traefik 23.44 ms**, **Caddy 24.13 ms**) kept tail latency nearly **2.8× tighter**.

## Zero-Downtime Config Reloads & SSE/WebSocket Traps

In **Scenario C**, we drove **20 VUs** of continuous HTTPS traffic while holding open a **5-second Server-Sent Events (`/stream`, 25 ticks)** connection, and triggered a live config swap (`X-Proxy-Gen: v1` → `v2`) mid-stream:

- **Caddy (`caddy reload`):** Swapped cleanly to `v2`, **0 failed HTTP requests**, **25/25 SSE ticks** delivered. Because Caddy validates the config over its local `:2019` Admin API before applying, a broken `Caddyfile` is rejected atomically without touching live traffic.
- **NGINX (`nginx -s reload`):** Also delivered **0 failed requests** and **25/25 SSE ticks** — *because* old worker processes stay alive until their existing long-lived connections close.

> [!WARNING]
> **The hidden NGINX reload trap.** If you run multiple rapid reloads while hundreds of WebSocket or SSE clients stay connected, old NGINX worker processes stay pinned in memory (`shutting down` state) alongside the new workers, quietly multiplying RAM usage until those clients disconnect. Always run `nginx -t` before `nginx -s reload`, and set `worker_shutdown_timeout` if you use long-lived streams.

- **Traefik (`watch: true` / Docker socket):** Updated dynamically to `v2` with **0 dropped requests** and **25/25 SSE ticks** without any reload command. Watch out for one edge case: on network filesystems or editors that use atomic `rename()` swaps, verify `watch: true` detects the inode change in your container mount.

## Copy-Paste Production Configs Compared

Nothing explains the ergonomics gap faster than seeing the exact files side by side for the same production setup (HTTPS, `zstd`/`gzip`, HSTS + `nosniff`, and streaming-safe proxying):

### 1. Caddy (`Caddyfile` — 9 lines with Auto-HTTPS)

Replace `:8443` + manual cert paths with your domain name and Caddy handles Let's Encrypt, HTTP→HTTPS redirects, OCSP stapling, and HTTP/3 automatically:

```txt title="Caddyfile" {1-2,9-11}
api.example.com {
  encode zstd gzip

  header {
    Strict-Transport-Security "max-age=31536000; includeSubDomains"
    X-Content-Type-Options "nosniff"
  }

  reverse_proxy app:8080 {
    flush_interval -1
  }
}
```

### 2. NGINX (`nginx.conf` — 39 lines, excluding Certbot)

Notice the required `Connection ""` header reset for upstream `keepalive 64`, `always` on `add_header` (otherwise NGINX drops security headers on `4xx`/`5xx` responses), and `proxy_buffering off` for SSE:

```nginx title="nginx.conf" {11,22-23,28,31}
worker_processes auto;
events { worker_connections 4096; }

http {
  sendfile on;
  gzip on;
  gzip_types application/json text/plain text/css application/javascript;

  upstream backend {
    server app:8080;
    keepalive 64;
  }

  server {
    listen 443 ssl;
    http2 on;
    server_name api.example.com;

    ssl_certificate /etc/letsencrypt/live/api.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/api.example.com/privkey.pem;

    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
    add_header X-Content-Type-Options "nosniff" always;

    location / {
      proxy_pass http://backend;
      proxy_http_version 1.1;
      proxy_set_header Connection "";
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_buffering off;
    }
  }
}
```

### 3. Traefik v3 (`compose.yaml` Docker Labels)

Traefik shines when you never want to edit a central proxy file as new microservices join your `compose.yaml`:

```yaml title="compose.yaml" {5-10}
services:
  app:
    image: my-api:latest
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.app.rule=Host(`api.example.com`)"
      - "traefik.http.routers.app.entrypoints=websecure"
      - "traefik.http.routers.app.tls.certresolver=letsencrypt"
      - "traefik.http.routers.app.middlewares=sec-headers,gzip-compress"
      - "traefik.http.services.app.loadbalancer.server.port=8080"
```

> [!TIP]
> **Security rule for Traefik in Docker.** Never bind `/var/run/docker.sock` directly as read-write into a public-facing proxy container. Either mount it `:ro` with `exposedByDefault: false`, or put `tecnativa/docker-socket-proxy` in front so a compromised proxy cannot gain root control over the Docker daemon.

## 4 Production Traps That Break After Launch

Benchmarks test happy-path JSON responses. Real outages happen on uploads, CDN headers, idle streams, and brute-force spikes:

| Production Trap | Caddy 2 | NGINX | Traefik v3 |
|---|---|---|---|
| **Large file uploads (`413` error)** | Unlimited by default (cap with `request_body`) | **Defaults to `1 MB`** (`client_max_body_size 1m`) — breaks uploads silently | Unlimited by default (`buffering` middleware optional) |
| **Built-in Rate Limiting** | **Requires plugin (`xcaddy` + `caddy-ratelimit`)** | **Built-in** (`limit_req_zone` / `limit_req`) | **Built-in** (`rateLimit` middleware) |
| **Idle WebSocket / SSE timeout** | No hard 60s cut unless configured | **Drops idle streams after `60s`** (`proxy_read_timeout`) | `respondingTimeouts.idleTimeout` (`180s` default) |
| **Real Client IP behind Cloudflare** | `trusted_proxies cloudflare` / CIDR block | `set_real_ip_from` + `real_ip_header CF-Connecting-IP` | `entryPoints.websecure.forwardedHeaders.trustedIPs` |

Two of these catch teams off guard every single week:

1. **The NGINX `1 MB` upload cliff (`413 Request Entity Too Large`):** Everything works in local tests with tiny JSON payloads. Ten minutes after launch, the first user uploads a 2 MB avatar or PDF and NGINX rejects it before your backend ever sees the request. Always set `client_max_body_size 25m;` (or your app's exact ceiling) explicitly in `nginx.conf`.
2. **Rate limiting without `xcaddy`:** This is Caddy's main batteries-not-included trade-off. NGINX (`limit_req_zone`) and Traefik (`rateLimit` middleware) ship rate limiting out of the box; standard Caddy requires building a custom binary with `xcaddy` and `caddy-ratelimit` (or placing Cloudflare / app-level rate limiting in front). If strict per-IP edge throttling in a stock Docker image is a hard requirement, **NGINX or Traefik** saves a custom Dockerfile.

## What About Nginx Proxy Manager and Kubernetes Gateway API?

Two questions come up on almost every **Caddy vs NGINX vs Traefik** thread:

![Decision matrix for Caddy vs NGINX vs Traefik plus Nginx Proxy Manager and Kubernetes Gateway API](https://media.alekseialeinikov.com/devops/c8a4f21d9e07/decision-1200.8dfe6277c5d121dd.webp "Pick Caddy for Docker Compose simplicity, NGINX for edge throughput, Traefik for dynamic labels — and plan Gateway API if moving to Kubernetes.")

1. **Caddy vs. Nginx Proxy Manager (NPM):** NPM wraps NGINX + Certbot behind a friendly web dashboard. For a homelab or a team that prefers click-ops over Git commits, NPM is fast to set up. For production engineering teams, **Caddy wins on reproducibility**: a 10-line `Caddyfile` lives in Git, passes PR review, and deploys identically across staging and production without SQLite state inside a GUI container.
2. **Moving from Docker Compose to k3s / Kubernetes?** Make sure you do not confuse two different projects:
   - **NGINX itself (`nginx:alpine` in Docker)** is **not** deprecated — it remains actively maintained.
   - **Kubernetes `ingress-nginx` (`kubernetes/ingress-nginx`)** *is* **retired as of March 2026** (archived and read-only, with no further CVE patches).

   If you plan to outgrow a single Docker host, do not invest in legacy `nginx.ingress.kubernetes.io/*` annotations. **Traefik v3** already implements **Kubernetes Gateway API** natively alongside Docker Compose, making it the smoothest transition path (see [k3s vs. k0s vs. MicroK8s vs. RKE2](https://www.alekseialeinikov.com/en/blog/topics/devops/k3s-vs-k0s-vs-microk8s-vs-rke2-2026) when picking your lightweight cluster).

## 30-Second Production Choice Checklist

- **Choose Caddy** if you run a single VPS or Docker Compose stack, want **10-line configs + automatic HTTPS + HTTP/3**, and value **35.7 MiB** active RAM with zero Certbot maintenance.
- **Choose NGINX** if you need **maximum raw throughput (17.7k+ req/s on 2 vCPU)**, heavy static caching, custom Lua/WAF modules, or already run hardened NGINX CI pipelines.
- **Choose Traefik** if containers frequently spin up and down via **Docker labels**, you want built-in middleware chains and a routing dashboard, and **160 MiB** active RAM fits comfortably in your host budget.

> [!NOTE]
> Read next:
> - [PostgreSQL in Docker for Production: Volumes, Shared Memory, Pooling & Backups](https://www.alekseialeinikov.com/en/blog/topics/data/postgresql-in-docker-production)
> - [Grafana k6 vs. Apache JMeter: Load Testing, Open Models & CI Gates](https://www.alekseialeinikov.com/en/blog/topics/devops/grafana-k6-vs-apache-jmeter-load-testing)
