ScaleScaleScaleScale

Great Architectures, Stacks & DevOps at Webscale

By Chris Ueland


Nginx HaProxy Varnish Comparison

Today we are going to explore the basic differences between the three most popular Proxy solutions: Nginx HaProxy Varnish Comparison. As your application grows and you need to scale in order to support traffic, DevOps and SysAdmins choose this three options to proxy their content to their backend servers.

Let’s try to see first what is a proxy, then a brief introduction to this servers, and later a comparison of the supported features by each one of them.

What is a Proxy?

A proxy is just a server that act in front of other backend servers. Proxies are used to balance traffic, support traffic spikes, protect from DDOS attacks and achieve high availability for web applications.

Varnish

Varnish is a reverse HTTP proxy and accelerator designed for high traffic websites. Unlike others, it allows you to proxy and load balance HTTP traffic only. Varnish is used by Wikipedia, NY Times, The Guardian and many others. Developed since 2006.

Nginx

Is the number #1 web server, load balancing and proxy solutions for high traffic websites. It’s actively developed, offers a free version and an enterprise version. Used by the top busy websites in the world like: WordPress.com, Zynga, Airbnb, Hulu, MaxCDN, is one of the top leading software solutions to achieve high availability and robust load balancing.

HaProxy

HAProxy is a free and open source software that provides load balancing and proxy server capabilities for TCP/HTTP protocols. Its well known to be fast and consume low system resources (CPU / memory usage). It’s compatible with Linux, Solaris, FreeBSD and Windows. It has been actively developed since 2002.

Nginx HaProxy Varnish Comparison

Important: this is a basic comparison, not a full detailed comparison. If you need full details about each server, please read the official docs of each product.

FeaturesNginxHaProxyVarnish
Full Stack Web ServerYesNoNo
Async ConcurrencyYesYesNo
Load BalancingYesYesYes
SSL OffloadingYesYesNo
Dynamic ModulesYesNoYes
Administration ConsoleYesYesYes
RealTime StatisticsYesYesYes
HTTPD/2 SupportYesYesNo
Windows SupportYesYesYes
Proxy CachingYesYesYes
TCP Proxy/LBYesYesYes
UDP Proxy/LBYesNoNo
 Mail ProxyYesYesNo
Commercial VersionYesYesYes
Actively DevelopedYesYesYes

Conclusion

As we saw in this Nginx HaProxy Varnish Comparison, the three pieces of software are great for Proxy solutions, however, Nginx has a big advantage, that is not only a proxy server but also a full stack web server, and has more intersting features than HaProxy and Varnish.

So, if you are going to choose one, then our suggestion is to go for Nginx, as it can fit in many scenarios, and changing the server/proxy software once a project is running can be a real pain, so start using Nginx from the begining as it can act as a web server, http proxy, mail proxy, and load balancer if needed.

Our second choice, if you are absolutely sure you won’t need a full stack web server is HaProxy, has many features and is super lightweight in terms of system resource usage.

Unfortunately, Varnish is becoming an obsolete software for modern web applications, more after the HTTP/2 launch, which they don’t think to be interesting enough to release a HTTP/2 supported version.

Further reading:

Popular search terms:

  • haproxy vs nginx
  • nginx haproxy
  • nginx haproxy difference
  • haproxy vs nginx performance
profile

Esteban Borges

Linux Geek, Webperf Addict, Nginx Fan. CTO @Infranetworking

  • bad_ip

    So, while I appreciate the volume of work that went into this article, I think I’d say that it’s preaching to people are who are just breaking into Devops. Really Nginx, HAPROXY and Varnish should be used in tandem.

  • CommanderWaffles

    Some peformance numbers would really be nice

  • Waqas

    How “Popular search terms” are being saved? 😀