httpd vs Nginx vs HAProxy

The three most popular tools for proxying HTTP(S) traffic are httpd, Nginx, and HAProxy. As more and more DevOps flock to “the cloud” for running their infrastructure, configuring elastic HTTP(S) proxies are becoming more and more important. (It should be noted that if you use a PaaS, then you won’t have a need for an HTTP(S) proxy as the service provider will route traffic for you… probably using one of these tools.) Which proxy you pick can make your job of ensuring an highly available environment easier.

What is an HTTP(S) proxy? HTTP(S) proxies are servers that act on the behalf of the HTTP server(s) that handles requests.
Why use an HTTP(S) proxy? They are usually used to load balance traffic, protect a possibly not-so-hardened web server, and A/B test new site releases.

http

httpd is by far the oldest in the bunch. It is arguably the first real web server; released in April 1996! As far as web servers go, it is extremely feature complete and is often found behind one of the other tools. As far as a proxy server, it is very much an after-thought. The original design simply wasn’t focused on being a proxy server.

Nginx

They claim to be the #1 web server for the top busiest websites in the world, and they do have an impressive list of “clients”: Netflix, box, hulu, etc. If you’re looking for a project that is equal parts web server and proxy, then Nginx is probably the best choice. With the first public release of Nginx being in October of 2004, it is coming up on almost a decade of serving web traffic.

HAProxy

Besides its 1990-era web site, HAProxy is anything but basic. It is the most complete proxy of the bunch in terms of load balancing capabilities. A number of popular sites rely upon HAProxy to ensure their site is always up: DISQUS, GitHub, Imgur, Instagram, etc. Tests with HAProxy have shown it can easily saturate a 10-Gig NIC. HAProxy was first released in November of 2000.

The Comparison

This is by no means a complete list of features for each project. See their respective sites for more information.

httpd Nginx HAProxy
Full Web Server Yes Yes No
“Concurrency” Pre-thread pool Async Async
Load Balancer No Yes Yes
SSL Offloading Yes Yes Yes
Plugins Dynamic Loading Statically Compiled No
Admin Console No No Yes
SPDY Support via Plugin via Plugin Yes
Runs on Windows Yes Yes No
TCP Proxy No No Yes

Conclusion

While httpd is a GREAT web server, it simply falls short as a proxy. Both Nginx and HAProxy are full-featured proxies and it really comes down to specific features you might be looking for. If caching is important to you, then Nginx might be a better choice. If advanced routing and load balancing is important to you, then HAProxy might be a better choice. Regardless, you can hardly “go wrong” with either of these projects. What’s more is that they seem to be in a bit of a feature war; when one project gets a feature, the other follows fairly quickly. So if you’re using one and it doesn’t have the feature you want, just wait a few months… or contribute yourself!