Apache versus Nginx and HaProxy – Which is the right Server for you?

Today I’m going to discuss three different web serving technologies, provide a quick list of their differences, and provide you enough cursory information so you can make the best choice for yourself.

Apache

The Apache web server launched in 1995 and is one of the first web servers ever released. It has been one of the most popular web servers since 1996 and has been in development under the Apache Foundation since 1999. Because of its popularity, the Apache web server is one of the best documents and best-supported web servers available. Though Apache2 is typically found installed on various Linux distributions, the foundation does have packages available for Windows, Mac, Unix, and BSD.

Apache is extremely extensible and customizable. It can handle most tasks under the umbrella of the server software itself through various plug-ins. For instance, Mcrypt, PHP, and SQL can be installed and then natively supported through Apache. It’s this versatility that has led to both Apache’s popularity its setbacks. It’s also the reason why Apache is so good at serving dynamically generated web content.

Nginx

First released in 2004, Nginx has become Apaches primary competitor. Nginx was originally developed by Igor Sysoev to handle Apaches shortcomings. Apache has the potential to be resource intensive which can potentially slow down websites. Nginx runs very lean, requiring much fewer hardware resources, and thus being able to handle far more TCP connection concurrently then Apache.

Nginx excels at serving static webpages but suffers with dynamically generate web pages. This is because Nginx depends on other software to perform tasks like preprocessing PHP or using SQL. The resource hand-off to these other apps does suffer a performance hit, though that performance hit has been hotly debated as of late.

Nginx also has additional features such as built-in load balancing, proxy services, and cache services. This makes Nginx a popular choice for such purposes due to its versatility. It’s not uncommon to see larger operations use both Apache and Nginx with Nginx acting strictly as the load balancer and cache service.

Haproxy Load Balancer

The Haproxy load balancer is an open-source software-based load balancer for both TCP and HTTP connections that run on Linux based OSes. Haproxy stands for high availability proxy. Appropriately named, the Haproxy software load balancer is designed to be used in a redundant, highly available network architecture. It is also written in C to minimize system resources and maximize efficiency.

It’s important to note that Haproxy runs on layer 7 of the network OSI model. This means that all load balancing is done at the application level, unlike other load balancers that run at layer 4 transport level. This makes the Haproxy load balancer highly customizable but also much more complicated in design.

Because of the high availability design, it’s best to use the Haproxy load balancer in a two or more configuration. This means that your floating static IP would be assigned to a single load balancer unless it fails, in which case the public IP of the network would be configured to fail over and point to the next load balancer. Both load balancers should be able to communicate with each other to be able to route traffic across multiple paths and to multiple servers within the network environment.

 

Leave a Reply

Your email address will not be published. Required fields are marked *