# HAProxy

> A high-performance TCP and HTTP load balancer known for reliability, fine-grained health checks and detailed stats. Free notes, key concepts, resources and a...

Canonical: https://www.internhack.in/roadmaps/tracks/devops/haproxy
Last updated: 2026-11-28

A high-performance TCP and HTTP load balancer known for reliability, fine-grained health checks and detailed stats.

Intermediate · about 5 hours · difficulty 3/5

Learn first: [How Web Servers Serve Traffic](https://www.internhack.in/roadmaps/tracks/devops/web-server-concepts)

**HAProxy** focuses on load balancing and proxying rather than serving files. It is used at very high traffic volumes and is a good choice when you need precise control over balancing, health checks and connection handling.

### What to learn

- Config sections: `global`, `defaults`, `frontend` (where traffic arrives), `backend` (pools of servers), and `listen` (both in one).
- `mode tcp` for layer 4 and `mode http` for layer 7 with **ACLs** to route by host, path or header.
- Balancing algorithms (`roundrobin`, `leastconn`, `source`) and active health checks (`option httpchk`).
- **Stick tables** for rate limiting and session persistence.
- The stats page and runtime API for draining servers during deploys.

### Where it fits

Great in front of databases (TCP), for large-scale HTTP balancing, and as a Kubernetes ingress option. It does not serve static sites, so it is often paired with a web server or CDN.

**Good enough to move on:** you can balance HTTP across a pool with health checks, route two hostnames to different backends, and drain a server via the runtime API.

## Key concepts

- **frontend and backend sections**
- **TCP vs HTTP mode**
- **ACL routing**
- **Health checks**
- **Stick tables**
- **Stats page and runtime API**

## Other options for this step

- [Nginx](https://www.internhack.in/roadmaps/tracks/devops/nginx): The most widely deployed web server and reverse proxy; learn its config model and the handful of directives that cover most real setups.
- [Caddy](https://www.internhack.in/roadmaps/tracks/devops/caddy): A modern web server with automatic HTTPS and a very short config format, great for small teams and simple deployments.
- [Apache HTTP Server](https://www.internhack.in/roadmaps/tracks/devops/apache): The long-standing web server still common in legacy stacks, shared hosting and PHP applications.

## Mini project

Put HAProxy in front of three app containers with leastconn balancing and HTTP health checks, expose the stats page, and drain one server during a simulated deploy.

## Check yourself

When would you choose mode tcp over mode http in HAProxy?

## Free resources

- [HAProxy documentation](https://docs.haproxy.org/) (haproxy.org)
- [HAProxy blog and tutorials](https://www.haproxy.com/blog) (HAProxy Technologies)

Previous: [Caddy](https://www.internhack.in/roadmaps/tracks/devops/caddy) · Next: [Apache HTTP Server](https://www.internhack.in/roadmaps/tracks/devops/apache)

## More in Web Servers and Reverse Proxies

- [How Web Servers Serve Traffic](https://www.internhack.in/roadmaps/tracks/devops/web-server-concepts)
- [Nginx](https://www.internhack.in/roadmaps/tracks/devops/nginx)
- [Caddy](https://www.internhack.in/roadmaps/tracks/devops/caddy)
- [HAProxy](https://www.internhack.in/roadmaps/tracks/devops/haproxy)
- [Apache HTTP Server](https://www.internhack.in/roadmaps/tracks/devops/apache)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [DevOps Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/devops)
