Three reverse proxies on two vCPUs
On 2 vCPU VMs, over reused connections, Caddy handled 35 to 46% of rpxy's requests per second and 43 to 52% of Ferron's. That held across six runs in two setups.
When every request needed a full TLS handshake, rpxy and Ferron did 1.6 to 1.7x Caddy's rate. Resuming the TLS session made all three only 4 to 16% faster.
A side quest into VM types and prices ended in the same place. On a $24 shared VM, changing the proxy bought more than any VM upgrade I tried.
What I wanted to know
I had a small Rust service behind Caddy on a 2 vCPU VM, and I wanted to know how much headroom it had if a lot of phones showed up at once. That's mostly a question about new TLS connections per second.
My first attempt was hey from my laptop against the public endpoint. It managed 127 requests a second while the proxy used 11% of one core. With 20 connections that's about 157 ms per request, which is my round trip and handshake to a server on another continent. It measured distance. So I rented VMs next to the server and tested over a private network.
Setup
Three runs on DigitalOcean, all on the same day:
| Run | Target | Load |
|---|---|---|
| A | s-2vcpu-4gb in lon1 | one 4 vCPU client |
| B | 4 vCPU in lon1, proxy pinned to 2 or 4 cores | two 4 vCPU clients |
| C | four 2 vCPU types in sfo2: shared, CPU-optimized, general, memory-optimized | two 4 vCPU clients |
The service answers GET /version with a 66-byte JSON body and Cache-Control: no-store. It ran on the target next to the proxy and shared its cores, except in run B where the proxy was pinned.
So every number here is proxy plus backend. A separate check showed all three proxies keep their upstream connection to the backend alive: 300 requests with Connection: close opened no new upstream sockets under any of them. The backend should cost about the same per request under each proxy. That keeps the ranking fair, but the ratios understate how different the proxies themselves are.
Caddy 2.10.2:
{
admin off
auto_https disable_redirects
skip_install_trust
https_port 8443
}
https://bench.example.test:8443 {
tls /certs/cert.pem /certs/key.pem
reverse_proxy 127.0.0.1:8080
}Ferron 3.0.0-rc.10. This file replaces the image's /etc/ferron/ferron.conf, which also turns off the JSON access log Ferron writes by default:
bench.example.test:8443 {
tls /certs/cert.pem /certs/key.pem
proxy http://127.0.0.1:8080
}rpxy 0.14.0, run with LOG_LEVEL=warn to keep per-request logging out of its numbers:
listen_port_tls = 8443
[apps.bench]
server_name = "bench.example.test"
tls = { tls_cert_path = "/certs/cert.pem", tls_cert_key_path = "/certs/key.pem" }
reverse_proxy = [{ upstream = [{ location = "127.0.0.1:8080" }] }]Caddy doesn't log requests unless you ask, so all three ran without access logs. Each got the same self-signed ECDSA P-256 certificate and ran in Docker with host networking, one at a time. I've swapped the test hostname for bench.example.test everywhere, outputs included.
The clients ran Ubuntu 24.04 with OpenSSL 3.0.13, wrk 4.1.0 and Python 3.12. OpenSSL 3.0 doesn't offer a post-quantum key share, so every handshake used X25519. Caddy negotiated TLS_AES_128_GCM_SHA256. Ferron and rpxy picked TLS_AES_256_GCM_SHA384. At 66 bytes the bulk cipher barely matters.
The summary numbers, image digests, configs and scripts are in /data/reverse-proxy-benchmark/.
My first run measured nothing
The first pass used hey from Ubuntu's package archive. It printed a requests-per-second figure for every proxy, including 12,334 for Ferron. Then I scrolled down to the error section.
Error distribution:
[107238] Get "https://bench.example.test:8443/version": remote error: tls: internal errorEvery request had failed, against all three proxies. hey was reporting how fast it collected TLS alerts. curl from the same client worked, so I moved to wrk and ApacheBench. I knew to read the status codes before the throughput line, and I still almost published that table.
Reused connections
wrk -t4 -c100 -d30s --latency https://bench.example.test:8443/versionRun A did two 30 second rounds with one client at 100 connections. Run C did one 15 second run per VM type with two clients at 50 connections each.
| Run | Caddy | Ferron | rpxy |
|---|---|---|---|
| A, round 1 | 5,698/s | 13,225/s | 15,722/s |
| A, round 2 | 6,154/s | 12,906/s | 17,820/s |
| C, shared | 7,121/s | 13,898/s | 15,388/s |
| C, CPU-optimized | 7,411/s | 16,466/s | 19,825/s |
| C, general | 6,794/s | 13,173/s | 17,076/s |
| C, memory-optimized | 7,739/s | 16,733/s | 20,029/s |
The target sat at 98 to 99% CPU in every run while the clients stayed under 25%. Per run, rpxy did 2.2 to 2.9x Caddy's throughput and Ferron 1.9 to 2.3x. rpxy beat Ferron in all six runs, by 1.1 to 1.4x.
wrk keeps a fixed number of connections busy, so at saturation its mean latency is just connections divided by throughput. For Caddy's two rounds, 100 / throughput gives 17.5 and 16.3 ms, and wrk measured 18.0 and 16.8 ms. The latency numbers restate the throughput table, so I've left them out.
The tail doesn't fall out of that arithmetic. In run A, Caddy's p99 was 3.8 to 4.5 times rpxy's, against throughput gaps of 2.8 to 2.9x.
A full TLS handshake on every request
This is the case that matters for a crowd of new phones. Each request is a new TCP connection and a full TLS 1.3 handshake.
My first two tries came from one client. ApacheBench, as four processes with 25 connections each, got Caddy to 1,650 to 1,680 new connections a second and rpxy to 2,742 to 2,851. Its Ferron numbers were useless, and the close_notify section below explains why. wrk with Connection: close then got 1,870 for Caddy, 2,990 for Ferron and 3,278 for rpxy, but the client and target both sat at 97 to 100% CPU, so I couldn't tell whose limit that was. wrk also starts its latency timer after the connection and handshake are done, so its latency for this mode leaves out the part I cared about.
So I wrote a small load generator in Python. Its timer covers the TCP connect, the handshake and the response, and it can resume the previous session:
start = time.monotonic()
try:
raw = socket.create_connection((host, port), timeout=5)
raw.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
tls = ctx.wrap_socket(raw, server_hostname=host, session=session if mode == "reuse" else None)
tls.sendall(request)Run C ran it as 16 processes on each of two clients for 15 seconds per cell. The target sat at 97 to 100% CPU on every type.
| VM type | Caddy | Ferron | rpxy |
|---|---|---|---|
| Shared | 1,882/s | 2,985/s | 3,160/s |
| CPU-optimized | 1,960/s | 3,284/s | 3,341/s |
| General | 1,820/s | 2,929/s | 3,093/s |
| Memory-optimized | 2,023/s | 3,311/s | 3,391/s |
rpxy did 1.68 to 1.70x Caddy on every type, and Ferron 1.59 to 1.68x. I only sampled one of the two clients. It ran at 48 to 87% CPU, and on the CPU-optimized and memory-optimized types it delivered 13 to 22% less than the other client for Ferron and rpxy, so those two cells may be slightly low. The single-client wrk run from run A landed within 4% of run C's shared type.
Here rpxy and Ferron were only 2 to 6% apart. Run B says that's partly the shared cores. With the proxy pinned to two cores and the backend free to use the other two, rpxy did 4,089 new connections a second against Ferron's 3,020. That's 1.35x, and rpxy's clients were at 90 to 92% CPU, so it's a floor.
Every proxy does the same X25519 exchange and P-256 signature per connection, though Go's crypto and the Rust proxies' are different implementations. I'd guess that fixed per-connection work is why the gap to Caddy narrows from about 2.5x to 1.7x.
Resumption buys 4 to 16%
A returning phone resumes its TLS session instead of doing a full handshake. I expected that to be several times cheaper.
Across run C's four VM types, resumption made Caddy 14 to 16% faster, Ferron 5 to 12% and rpxy 4 to 8%. The load generator confirmed that 99.9% of those connections resumed.
In run B, with the proxy pinned to two cores, resumption was worth 19% for Caddy, 34% for Ferron and 13% for rpxy. The clients there ran at 46 to 92%, and resumption also saves the client its certificate check, so a busy client inflates the gain. Treat run B's numbers as an upper bound.
TLS 1.3 resumption skips the certificate and its signature. As far as I can tell, Go's TLS stack and rustls only resume with a fresh key exchange, TLS 1.3's psk_dhe_ke mode, so the X25519 work still happens on every connection. The TCP connect, the accept and the HTTP request stay too.
Ferron skips close_notify
ApacheBench reported this for Ferron, per process:
Complete requests: 21511
Failed requests: 21511
(Connect: 0, Receive: 0, Length: 21511, Exceptions: 0)ApacheBench speaks HTTP/1.0, so I checked HTTP/1.1 with openssl s_client and Connection: close. Caddy ends the connection properly:
HTTP/1.1 200 OK
Content-Length: 66
Connection: close
<<< TLS 1.3, Alert [length 0002], warning close_notify
>>> TLS 1.3, Alert [length 0002], warning close_notifyFerron sends the whole response and closes the socket without the alert:
HTTP/1.1 200 OK
content-length: 66
connection: close
>>> TLS 1.3, Alert [length 0002], fatal decode_error
40B74BC07A700000:error:0A000126:SSL routines:ssl3_read_n:unexpected eof while reading:../ssl/record/rec_layer_s3.c:316:rpxy sends close_notify too. With content-length set, curl and wrk read Ferron's responses without complaint, so nothing was lost here. It's still a spec violation. RFC 8446 section 6.1 says each party MUST send close_notify before closing its write side, and clients that enforce it, ApacheBench among them, report every Ferron response as failed.
Rate limiting
Caddy doesn't ship a rate limiter. I built one in with xcaddy, cross-compiling from an arm64 Mac:
docker run --rm --platform linux/arm64 \
-e GOOS=linux -e GOARCH=amd64 -e CGO_ENABLED=0 \
-v "$PWD/caddy-rl:/out" caddy:2.10.2-builder-alpine \
xcaddy build v2.10.2 --with github.com/mholt/caddy-ratelimit --output /out/caddyIt ends with Failed to set capabilities on file '/out/caddy': Not supported, which only matters if a non-root user needs a port below 1024. It does mean the limited Caddy is a different binary from the one in the throughput tables.
{
order rate_limit before reverse_proxy
}
https://bench.example.test:8443 {
tls /certs/cert.pem /certs/key.pem
rate_limit {
zone per_ip {
key {remote_host}
events 50
window 1s
}
}
reverse_proxy 127.0.0.1:8080
}Ferron has a limiter built in:
bench.example.test:8443 {
tls /certs/cert.pem /certs/key.pem
rate_limit {
rate 50
burst 50
key remote_address
}
proxy http://127.0.0.1:8080
}rpxy doesn't have one. Its example config says "rpxy does not provide a per-IP limit".
Over a single 20 second run from one address, Caddy let 1,000 to 1,040 requests through and Ferron 1,099 to 1,101. Both answered the rest with 429, Ferron with Retry-After: 1. Caddy's limiter is a sliding window and Ferron's a token bucket, so the counts aren't directly comparable, and Ferron's extra 100 is more than its burst of 50 explains.
The size of the refusals surprised me more. Caddy's 429 responses averaged 155 to 175 bytes on the wire and Ferron's about 4.5 KB, 25 to 29 times bigger. In the keep-alive run, Ferron's refusals went out at 62 MB/s against Caddy's 1.4 MB/s.
A per-IP limit is also the wrong tool for my question. Mobile carriers put many subscribers behind one address with carrier-grade NAT, so a crowd of real phones can look like one abusive client. Behind a load balancer, remote_host is the balancer.
Caching a no-store response
/version sends Cache-Control: no-store, so a correct cache must never keep it. I turned caching on, requested the endpoint, restarted the service with a different revision string, and requested it again.
bench.example.test:8443 {
tls /certs/cert.pem /certs/key.pem
cache
proxy http://127.0.0.1:8080
}Ferron served the new revision immediately and said why it hadn't stored the old one:
cache-control: no-store
cache-status: FerronCache; fwd=miss; stored=false; detail=response-no-storeThat detail= field is lovely when you're debugging a cache. rpxy's experimental cache also served the new revision straight away, without saying what it decided. Caddy needs the cache-handler plugin to cache anything.
Side quest: what the VM costs
Run C was meant to check whether the proxy ratios held on different hardware. Once I added the prices, it turned into a second question. Is a faster VM worth more than a faster proxy?
| 2 vCPU type | $/month | CPU | Reused req/s | Full handshakes/s | Handshakes/s per $ |
|---|---|---|---|---|---|
Basic, shared (s-2vcpu-4gb) | 24 | DO-Regular | 12,136 | 2,676 | 111 |
CPU-optimized (c-2) | 42 | Xeon Platinum 8280 | 14,567 | 2,862 | 68 |
General purpose (g-2vcpu-8gb) | 63 | Xeon Platinum 8168 | 12,348 | 2,614 | 41 |
Memory-optimized (m-2vcpu-16gb) | 84 | Xeon Gold 6248 | 14,834 | 2,908 | 35 |
Rates are the mean of the three proxies, one 15 second run per type. Prices are DigitalOcean's list prices on the day.
The cheapest upgrade was the proxy. On the same $24 Basic box, switching from Caddy to rpxy raised reused-connection throughput by 116% and full handshakes by 68%. Moving Caddy to the $42 CPU-optimized box raised both by 4%.
The dedicated types do win in one place. On reused connections rpxy did 29 to 30% more on the CPU-optimized and memory-optimized types than on Basic. That's the only VM effect bigger than the 8 to 13% run A saw between identical rounds. Ferron's 18 to 20% on the same types is borderline. Even rpxy's gain costs 75% more per month for 29% more throughput.
Handshakes barely moved. The dedicated types ranged from 2% slower to 9% faster than Basic. General purpose and memory-optimized mostly buy RAM, and the proxies sat at 10 to 29 MiB of it after a run.
What Basic costs you is predictability. Its vCPUs are shared, it reports its CPU as DO-Regular, and mpstat counts time a neighbour steals as busy. A 15 second run on a quiet afternoon can't show what a busy neighbour does to the tail at 3am. Dedicated cores buy that predictability. Here they didn't buy much throughput.
Scaling up looked worse per dollar than scaling out. Pinning Caddy to four cores instead of two took it from 1,996 to 2,907 new connections a second, 46% more. A 4 vCPU Basic box costs $48, twice the 2 vCPU one. Nothing was saturated at four cores, so 46% is a floor, but it's a long way from the 2x a second $24 box would add. Ferron and rpxy saturated both clients at four cores, so I can't say how they scale.
Scaling out has its own bill. It needs a load balancer or DNS in front, and in my case the database lives on the same VM and would have to move first.
What this doesn't tell you
None of this is 10,000 connections arriving in the same second. One ApacheBench process in run A already saw a 1,038 ms connect with 25 connections per process, which looks like a SYN retransmit. rpxy's current defaults on its develop branch cap it at 512 clients with a 1,024 listen backlog. A real test of that needs many clients and an open arrival rate.
Every test used HTTP/1.1, and phone apps mostly negotiate HTTP/2 and keep one connection open. Every VM-type cell is a single run. I didn't profile anything, so I can't say where Caddy's extra CPU or its p99 tail goes, or why hey failed. I didn't test Caddy's cache plugin.
Where that leaves me
The service doesn't need any of this headroom, and Caddy's automatic certificates are worth more to me than a factor of two I'm not using, so it stays on Caddy, on a $24 Basic VM. If it ever needs more, I'd change the proxy first, then add a second Basic VM once the database lives elsewhere, and only then look at bigger or dedicated ones.
If that changes, rpxy is the faster proxy once it has cores to itself, but its client cap needs raising before it meets a crowd. Ferron is the one I'd pick for a limiter and a cache in the proxy itself, once 3.0 leaves release candidate and sends close_notify.