In the open source world, some very smart products are often used to build a high-performance, reliable, and scalable architecture. HAProxy and Varnish are both in this category. Since we can’t really compare a reverse proxy cache and a reverse proxy load balancer, I’m just going to focus on the commonalities of both software as well as the advantages of each of them. The list is not exhaustive, and I will only focus on the most used and most interesting features. So feel free to add a comment if you want me to complete the list.

HAProxy & Varnish: Similarities

HAProxy and Varnish both have:

  • reverse proxy mode

  • advanced HTTP features

  • no SSL offloading

  • client-side HTTP 1.1 with keepalive

  • tunnel mode available

  • high performance

  • basic load balancing

  • server health checking

  • IPv6 ready

  • management socket (CLI)

  • professional services and training available

HAProxy & Varnish: Differences

#1 HAProxy Benefits

The features below are available in HAProxy but aren’t in Varnish:

  • advanced load balancing

  • multiple persistence methods

  • DOS and DDoS mitigation

  • advanced and custom logging

  • web interface

  • server/application protection through queue management, slow start, etc.

  • SNI content switching

  • named ACLs

  • full HTTP 1.1 support on the server side, but keep-alive

  • works at TCP level with any L7 protocol

  • proxy protocol for both client and server

  • powerful log analyzer tool (halog)

#2 Varnish Benefits


The features below are available in Varnish but aren’t in HAProxy:

  • caching

  • grace mode (stale content delivery)

  • saint mode (manages origin server errors)

  • modular software (with a lot of modules available)

  • intuitive VCL configuration language

  • HTTP 1.1 on the server side

  • TCP connection re-use

  • the edge side includes (ESI)

  • a few command line tools for stats (varnishstat, varnishhist, etc…)

  • powerful live traffic analyzer (varnishlog)

Conclusion


They work very well together: Varnish will make the website faster by offloading static object delivery to itself, while HAProxy can ensure smooth load balancing with smart persistence and DDoS mitigation.

Despite being “competitors” on a few features, each of them has its own domain of expertise where it performs very well: HAProxy is a reverse proxy load balancer, and Varnish is a reverse proxy cache.

To be honest, here at HAProxy Technologies, we often encounter Varnish deployed alongside the Aloha load balancer or HAProxy in the infrastructures we work on. And if that is not the case, we often recommend that the customer deploy one if we feel it would improve their website's performance.

Recently, I had a discussion with Ruben and Kristian from Varnish when they came to Paris, and they told me that they also often see an HAProxy when they work on infrastructures where Varnish is deployed.

Subscribe to our blog. Get the latest release updates, tutorials, and deep-dives from HAProxy experts.