HAProxy is a fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications. It serves as a gateway that sits between clients and backend servers to optimize resource utilization and minimize response time.
How it works
The engine operates using a single-process, event-driven model. It evaluates incoming requests against Access Control Lists (ACLs) and routes them to server pools defined in the backend section. Key features include:
- Layer 7 Switching: Routing based on URLs, cookies, or HTTP headers;
- SSL Termination: Offloading encryption tasks from application servers;
- Persistence: Maintaining user sessions on the same backend node using sticky cookies.
It is commonly used to scale web clusters, manage traffic spikes, and provide seamless failover. If a backend server fails a health check, HAProxy immediately stops sending traffic to it until it becomes healthy again, preventing user-facing errors.
HAProxy is used by high-traffic platforms like GitHub, Reddit, and Stack Overflow. It is capable of saturating a 10 Gbps network link with minimal CPU overhead, making it one of the most efficient software load balancers available today.