ConfigsApr 15, 2026·3 min read

HAProxy — High-Performance TCP/HTTP Load Balancer

The reliable, open-source load balancer that runs the internet — L4/L7, HTTP/2, HTTP/3, and TLS 1.3, with millisecond reloads.

TL;DR
HAProxy is the open-source load balancer powering high-traffic sites with L4/L7 routing, HTTP/2, HTTP/3, and hot reloads.
§01

What it is

HAProxy is an open-source, high-performance TCP and HTTP load balancer and reverse proxy. It handles Layer 4 and Layer 7 load balancing, supports HTTP/2, HTTP/3 (QUIC), and TLS 1.3, and can reload configurations with zero downtime. HAProxy powers some of the highest-traffic websites and is a standard component in production infrastructure stacks.

HAProxy is designed for operations teams and platform engineers who need a reliable, fast, and configurable load balancer for production workloads.

§02

How it saves time or tokens

HAProxy handles millions of concurrent connections on a single instance, reducing the need for complex multi-tier load balancing setups. Its configuration file is declarative and well-documented, meaning you can set up production-grade load balancing in a single config file rather than stitching together multiple tools. Hot reloads let you change routing rules, add backends, or update TLS certificates without dropping any connections.

§03

How to use

  1. Run HAProxy via Docker:
docker run -d --name haproxy -p 80:80 -p 8404:8404 \
  -v $(pwd)/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro \
  haproxy:3.1
  1. Create a minimal haproxy.cfg:
global
    maxconn 4096

defaults
    mode http
    timeout connect 5s
    timeout client 30s
    timeout server 30s

frontend http_front
    bind *:80
    default_backend app_servers

backend app_servers
    balance roundrobin
    server app1 10.0.0.1:8080 check
    server app2 10.0.0.2:8080 check

listen stats
    bind *:8404
    stats enable
    stats uri /stats
  1. Access the stats dashboard at http://localhost:8404/stats to monitor backend health and connection metrics.
§04

Example

HTTPS termination with Let's Encrypt certificates and health checks:

frontend https_front
    bind *:443 ssl crt /etc/haproxy/certs/ alpn h2,http/1.1
    http-request redirect scheme https unless { ssl_fc }
    use_backend api_servers if { path_beg /api }
    default_backend web_servers

backend web_servers
    balance leastconn
    option httpchk GET /health
    server web1 10.0.0.1:3000 check inter 5s fall 3 rise 2
    server web2 10.0.0.2:3000 check inter 5s fall 3 rise 2

backend api_servers
    balance roundrobin
    server api1 10.0.0.3:8080 check
    server api2 10.0.0.4:8080 check
§05

Related on TokRepo

§06

Common pitfalls

  • Not setting proper health check intervals. Without health checks, HAProxy continues sending traffic to failed backends. Always configure option httpchk with reasonable inter, fall, and rise values.
  • Using mode tcp when you need HTTP features like path-based routing or header manipulation. TCP mode is faster but lacks Layer 7 features.
  • Not monitoring the stats page in production. The HAProxy stats dashboard provides real-time visibility into connection counts, error rates, and backend health. Enable it and monitor it.

Frequently Asked Questions

How does HAProxy compare to Nginx for load balancing?+

Both are capable load balancers. HAProxy is purpose-built for load balancing and excels at high-connection-count scenarios with advanced health checking, session persistence, and connection queuing. Nginx is more versatile (web server, reverse proxy, load balancer) but HAProxy offers more granular load balancing features.

Does HAProxy support HTTP/3?+

Yes. HAProxy 2.6+ supports HTTP/3 with the QUIC protocol. You enable it by adding the quic4 or quic6 bind option. This requires building HAProxy with QUIC support or using a binary that includes it.

Can HAProxy do zero-downtime reloads?+

Yes. HAProxy supports seamless reloads where new connections use the updated configuration while existing connections complete on the old configuration. No connections are dropped during a reload.

What load balancing algorithms does HAProxy support?+

HAProxy supports roundrobin, leastconn, source (sticky by IP), uri, url_param, hdr (sticky by header), and random with configurable weights. You can also use custom hashing for consistent routing.

Is HAProxy suitable for Kubernetes?+

Yes. HAProxy provides an Ingress Controller for Kubernetes that brings HAProxy's load balancing features to Kubernetes services. It supports TCP, HTTP, and gRPC routing with the same configuration flexibility as standalone HAProxy.

Citations (3)

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets