Under the hood
How the application and dedicated load balancers and the CDN edge run on one Rust proxy we wrote, why we built it instead of driving HAProxy or Pingora, what it measures against HAProxy and the provider's load balancers, and where it still falls short.
The application and dedicated load balancers and the CDN edge are one program, lb-proxy-rs,
a Rust proxy we wrote on tokio, hyper and rustls. The decision that shaped it was not to be faster
than HAProxy: it was to own the data plane, so that per-request logs, live per-target numbers,
host and path rules, drains and hot reloads are things the proxy does natively rather than things
bolted around a config file. The lb11–lb31 types stay the provider's load balancers; we offer
both, for reasons this page gives.
What runs where
client ──DNS──▶ fleet address on the active node, :80 / :443
│ Host (http) or SNI + Host (https) picks
▼ the tenant
lb-proxy-rs: one single-threaded tokio runtime per core
connection cap · GCRA rate limit · web ACL · rules
target pick · health checks · access log
│ HTTP/1.1, X-EWS-LB-Token
▼
targets, over their public addresses
standby node: same proxy, same health checks, idle
control plane: document pulled every few seconds,
counters posted every 10 s, logs in batches;
it alone moves the fleet's addresses on failoverEach worker thread is its own current_thread tokio runtime: a connection is accepted on one
core and lives there, so the hot path shares nothing across cores. All workers accept from one
shared listening socket (a per-worker SO_REUSEPORT socket is an option; the shared one measured
better). Control work (document pull, reports, failover watch, GeoIP, rate sync) runs on a small
separate runtime on the main thread.
The node holds no provider credentials. It pulls its document with an ETag, keeps the last good copy on disk and keeps serving it if a new one does not parse. A reload never drops a connection: listeners restart only when a port, protocol or PROXY setting changes, and a removed one drains for 30 s. To targets the proxy speaks HTTP/1.1 from a per-thread, per-target LIFO pool of idle connections (at most 4,096 per target and thread, closed after 60 s idle). On the public fleet the standby polls the active node's health (300 ms, three misses) and then asks the control plane, which probes for itself before moving the addresses; the node never moves one. The fleet's machine types and the failover as seen from outside are in What runs on your machines.
The CDN edge is the same binary with a different document on a separate fleet: one node per location, all active, spread by multi-answer DNS. A request meets the WAF, then the RAM cache, then the disk tier, then the origin over https. Global WAF rate limits are synced peer to peer over UDP once a second, HMAC-SHA256 signed, carrying 64-bit hashes of rate keys rather than client addresses; a peer silent for 5 s drops out and the limit fails open. The edge's capacity numbers are on the CDN page.
What we built, and what we did not
Ours: routing by host and path, target choice (nginx's smooth weighted round robin, least connections counted until the response body ends, sticky cookies), forwarding headers and hop-by-hop stripping, WebSocket upgrade, PROXY protocol to targets, the access log, active health checks, an SNI resolver over a hot-swapped certificate store that caps handshakes per tenant before it signs anything, GCRA rate limits per tenant at one compare-and-swap per request, the upstream pool, config reload and the failover watch. On the edge: a RAM cache with miss collapsing and CloudFront-style caching rules, a disk tier, a WAF engine with the AWS WAF model, our own "EWS Core" rule set (inspired by the OWASP Core Rule Set, not a port of it), a JavaScript proof-of-work challenge, SSRF-checked origin resolution and the UDP rate sync. 73 tests cover it: unit, end-to-end, and property-based at 4,096 cases per property.
Off the shelf: tokio 1.54; hyper 1.12 for HTTP/1.1 and HTTP/2 serving and the HTTP/1.1 client,
with its strict parsing; hyper-util; rustls 0.23 on the aws-lc-rs provider with tokio-rustls,
webpki and webpki-roots; ppp for PROXY protocol parsing; arc-swap for the hot config swap;
mimalloc as allocator; reqwest for control-plane calls; maxminddb over the DB-IP Lite database
(CC BY 4.0) for GeoIP. The release build uses fat LTO and one codegen unit, +lse atomics on
arm64 and x86-64-v3 on x86. Around the proxy: Linux nftables for per-source caps on the edge,
kernel sysctls (SYN cookies among them), and the provider's floating and alias addresses, which
the control plane moves.
Pingora, tokio + hyper + rustls, or HAProxy/Envoy driven by an agent. Three options were on the table at the start. As recorded, nothing is CPU-bound at two vCPUs, so the prototype's job was to show what owning the data plane buys; it was built on tokio + hyper + rustls, with the rule that HAProxy plus a config agent would stay the default until a measured advantage existed. Pingora was set aside because its edge-scale strengths are irrelevant at per-customer scale and its layer 4 is weaker. The risks written down were HTTP correctness (smuggling, hop-by-hop headers, HTTP/2 resets), least-connections leaks, draining before an address move, PROXY only from trusted peers, and fair benchmarks.
Own proxy over HAProxy. The product is per-request logs, live per-target numbers, rules, drain and hot reload: native in the prototype, and around HAProxy a config regenerator, a socket API and a log sidecar. HAProxy's keep-alive lead was understood (it sat in the HTTP client of the time) and judged closable; the handshake lead was ours. What motivated the exercise were the recorded gaps of the provider's load balancer: a black box with no per-request log, no live per-target load, no host or path rules, about 45 s to eject a dead target, and hard connection caps.
Offer both. Moving every type onto our fleet would have lost lb11's best requests-per-euro
row and made every customer pay for our failover pair.
A shared fleet, not a pair per customer. A per-customer HA pair cannot undercut lb11: the
cheapest pair costs €15.98 a month against €6.99. So many tenants share one pair, as the provider
does, under the caps in Load balancer types. Private dedicated load
balancers run on a pair in your VPC; a proxy on the data nodes themselves was rejected.
Tuning kept and rejected. On two pinned Ampere Altra cores (raw output not kept):
thread-per-core brought +29 % on keep-alive, our own upstream pool +13 %, the build flags +5–12 %.
Rejected: opening the upstream connection inline (−29 % on a dedicated-2), separate ALPN-chosen HTTP/1.1 and HTTP/2
servers (±3 %), another allocator (about 3 % of the profile). The profile is 50–58 % kernel, about
40 % user, one read and one write syscall per side per request, the same count as HAProxy.
On the edge. Our own WAF engine rather than Coraza; a separate edge fleet, since it must not share an address or a failure domain with load balancer tenants, and multi-answer DNS is the cheapest all-active scheme without anycast; rate sync peer to peer rather than through the control plane (lag, and a flood would hit it) or Redis (a round trip per request and a new stateful part). No evaluation of nginx or Caddy as the load balancer was ever written; we do not claim one.
Benchmarks
How to rerun these: the two 2026-11-21 tables use only public tools (wrk, h2load, nginx, HAProxy from the distribution) with the commands below; the scripts that set the machines up and pin the cores are an internal tool, not published, and do nothing the setup paragraphs do not say. The 2026-11-12 table's raw output and setup script were not kept.
Head to head with HAProxy, 2026-11-21, raw output kept
Our arm-16 test box (16 Neoverse-N1 cores, 32 GB, arm64), 15:47–15:56 UTC, everything over
loopback on one machine, cores pinned: the proxy on 2 cores (lb-proxy-rs with 2 workers;
HAProxy 2.8.32 with nbthread 2, cpu-map and http-reuse always), nginx 1.27.5 backends on 4
cores (a 19-byte body and a 100 KiB file), the generator on 8 cores (wrk 4.1.0, h2load 1.59.0).
Self-signed ECDSA P-256 certificate. Rounds interleaved (ours, HAProxy, ours, …), 3 rounds of
12 s per row; means, with min–max where it matters; 0 errors on every row. The backends alone
answered 223,109 req/s.
| Row, 2 proxy cores | lb-proxy-rs req/s |
HAProxy req/s | p99 ours / HAProxy |
|---|---|---|---|
| HTTP keep-alive, 256 conn | 30,820 (30,610–31,239) | 34,989 (34,086–35,768) | 10.8 / 10.6 ms |
| HTTP, new connection per request | 19,556 | 22,862 | 19.9 / 12.3 ms |
| HTTP, 100 KiB body, 64 conn | 14,609 | 13,566 | 7.3 / 6.5 ms |
| HTTPS keep-alive, 256 conn | 27,981 | 26,032 | 10.7 / 33.2 ms |
| HTTPS, full TLS 1.3 handshake per request | 5,658 (5,483–5,767) | 2,168 (2,113–2,203) | 52.2 / 68.4 ms |
| HTTP/2, 64 conn × 10 streams | 39,674 | 42,748 | not reported |
| TCP (layer 4) listener, keep-alive | 63,268 | 61,095 | 5.8 / 6.0 ms |
What it shows: on two cores we are about 12 % behind HAProxy on plain HTTP keep-alive, 14 % on new HTTP connections and 7 % on HTTP/2. We are ahead by about 2.6× on TLS handshakes, 7 % on HTTPS keep-alive (with a p99 of 10–11 ms against 26–47 ms), and a little on large bodies and TCP. What it does not show: a network card (loopback has no NIC and no virtio queue), the x86 machines the fleet runs on (this is arm64; the next table is), or an unloaded host (the generator ran on the same machine, which other work shared too).
wrk -t8 -c256 -d12s --latency http://HOST:PORT/
wrk -t8 -c256 -d12s --latency -H 'Connection: close' http://HOST:PORT/
wrk -t8 -c64 -d12s --latency http://HOST:PORT/100k
wrk -t8 -c256 -d12s --latency https://HOST:PORT/
wrk -t8 -c256 -d12s --latency -H 'Connection: close' https://HOST:PORT/
h2load -t8 -c64 -m10 -D 12 https://HOST:PORT/
wrk -t8 -c256 -d12s --latency http://HOST:TCP_PORT/On the fleet's machine type, 2026-11-21, raw output kept
The same rows on the machine a load balancer node runs on: a performance-4 (4 shared AMD vCPU,
EPYC Genoa, 8 GB, x86-64) running one proxy at a time on all four cores (lb-proxy-rs with 4
workers, HAProxy 2.8.30 from Ubuntu 24.04 with nbthread 4), driven over the private network from
a dedicated-16 (16 dedicated AMD vCPU) in the same zone (de1a) that also ran the nginx 1.24
backends on 4 of its cores and wrk/h2load on the other 12. 18:59–19:09 UTC, 3 interleaved rounds of
12 s per row, the same commands as above against the proxy's private address; 0 errors. The backends
alone answered 253,187 req/s.
Row, performance-4 |
lb-proxy-rs req/s |
HAProxy req/s | p99 ours / HAProxy |
|---|---|---|---|
| HTTP keep-alive, 256 conn | 66,141 | 65,275 | 6.6–9.5 / 6.6–6.9 ms |
| HTTP, new connection per request | 22,732 | 24,091 | 10.9–12.4 / 10.2–13.4 ms |
| HTTP, 100 KiB body, 64 conn | 5,841 | 5,500 | 15.6–15.9 / 16.9–17.5 ms |
| HTTPS keep-alive, 256 conn | 63,095 | 65,227 | 6.1–7.4 / 7.0–8.7 ms |
| HTTPS, full TLS 1.3 handshake per request | 14,023 (13,670–14,302) | 7,080 (6,896–7,385) | 18–25 / 49–79 ms |
| HTTP/2, 64 conn × 10 streams | 89,963 | 95,277 | not reported |
| TCP (layer 4) listener, keep-alive | 65,914 | 66,181 | 5.8–6.6 / 6.0–6.6 ms |
What it shows: on the fleet's machine both proxies stop at the same place, about 66,000 small
requests per second whether HTTP, HTTPS or plain TCP, so that ceiling is the machine (its network
path and shared vCPUs), not either proxy; the 100 KiB row is 4.5–4.8 Gbit/s for both. Where the
proxy itself is the work, we do about twice HAProxy's TLS handshakes with a third of its p99, and
HAProxy is about 6 % ahead on new HTTP connections and HTTP/2. What it does not show: the proxy's
CPU at that ceiling (not recorded), or the public path (this ran over the private network). The
2026-11-12 run below had a performance-4 near 96,000 req/s keep-alive under different conditions
whose raw output is lost; we cannot say which of the two a given machine will meet.
On cloud machines, 2026-11-12 (raw output not kept)
One proxy machine at a time in zone de1a (Falkenstein), generator a dedicated-8 (8 dedicated
AMD vCPU) with the same commands, two dedicated-4 (4 dedicated AMD vCPU, 16 GB) nginx backends
over the VPC, 12 s per row, 0 errors. HAProxy 2.8 on the same machine with all its threads. Rows
near 100,000 req/s were close to the generator's and backends' own limit and read as "at least".
| Machine, HTTP keep-alive req/s | lb-proxy-rs |
HAProxy | TLS handshakes/s, ours / HAProxy |
|---|---|---|---|
performance-2 (2 shared AMD vCPU, 4 GB) |
31,290 | 30,901 | 4,148 / 1,791 |
performance-4 (4 shared AMD vCPU, 8 GB), the fleet's type |
96,536 | 101,859 | 15,600 / 8,647 |
dedicated-2 (2 dedicated AMD vCPU, 8 GB) |
53,488 | 59,422 | 5,165 / 2,892 |
dedicated-4 |
103,072 | 104,855 | 14,470 / 7,158 |
The provider's load balancers on the same day and path: lb11 23,334 req/s keep-alive, lb21
44,172, lb31 78,813 (lb11 handshakes 2,405/s). Over the public path a customer's traffic
takes, a performance-4 node answered 81,106 req/s keep-alive and 87,107 HTTPS keep-alive; the
public path costs about 20 %. A dedicated-2 node held 60,000 keep-alive connections, refused
none and answered a second request on all; RSS was 2.0 GB at about 57,000 (about 35 KB per
connection).
Known limits
- On a
dedicated-2we were still about 10 % behind HAProxy on plain keep-alive (level on adedicated-4); what remains is hyper's user-space dispatch. - Targets are reached over HTTP/1.1 only; there is no HTTP/2 to targets and no re-encryption.
- No per-target connection limit or queue (HAProxy's
maxconnstyle): a slow target gets as many connections as clients bring. - A 2-vCPU shared machine hangs on one virtio NIC queue: at a fixed 20,000 req/s its p99 swung
between 6 and 250 ms across runs. The same queue caps a
performance-4edge node near 138,000 small responses a second. - Failover has a floor of about 5–7 s (plus about 1.2 s per extra dedicated IPv4 on the same node) and drops every open connection; the proxy shares no connection state between the pair.
- Active/standby: the standby's capacity sits idle, and no failover happens while the control plane is unreachable.