NGINX and HAProxy are often compared to another and have revolutionized the IT industry by providing for free what other companies charge tens of thousands of dollars for. Both NGINX and HAProxy are both free open source application delivery controllers that are used in front of backend servers to scale and improve performance.
So which one should you use ? Choosing between NGINX and HAProxy has to do with what feature set you are most interested in to build on your infrastructure. NGINX and HAProxy together are a fast combination and can each be used to accomplish different tasks. Let us first compare the performance of HTTP load balancing between NGINX and HAProxy. There are many benefits to using load balancing. One is to scale out and handle more concurrent users, and second is high availability - if one server fails, others are available to ensure the application stays online.
Consider load balancing HTTP requests to two containers acting as web servers listening on port 80 and 85 respectively using either NGINX open source or HAPRoxy community edition. The containers will statically deliver a file of variable size running on a amazon c4 large instance.
I will now share the NGINX and HAProxy configuration used in this performance test. Feel free to copy the example configurations to your fresh installation. Please note that you may have to change the IP addresses included in the configurations below. The IP address of the upstream server should correspond to the public ip address of Amazon EC2 instance C (where the web server containers are running). In this example, it is 34.214.114.56.
#NGINX configuration
server {
listen 80;
proxy_http_version 1.1;
proxy_set_header Connection "";
keepalive_requests 50;
keepalive_timeout 10s;
location / {
proxy_pass http://backend;
}
}
upstream backend {
server 34.214.114.56:80 max_conns=750;
server 34.214.114.56:85 max_conns=750;
keepalive 200;
}
} #END
#HAProxy configuration
global
nbproc 2
cpu-map 1 0
cpu-map 2 1
maxconn 6000
tune.maxaccept 50000
defaults
mode http
bind-process 1 2
option abortonclose
option dontlog-normal
frontend http_front
bind *:80
default_backend http_back
backend http_back
balance roundrobin
server web01 34.214.114.56:80 check maxconn 750
server web02 34.214.114.56:85 check maxconn 750
Now we will start a thread of 100 channels sending http requests over a time span of 10 seconds on machine A (client machine). We will then direct the HTTP requests to machine B (The machine that will either be running NGINX or HAProxy to load balance the requests). Run the following command on Amazon EC2 instance A:
$ wrk -t 1 -c 100 -d 10s http://{public-ip-machine-B}:80
Here are the results of the performance comparison between NGINX and HAPRoxy in terms of RPS (Requests per Second).
For a request size of 1 KB, NGINX can process 92341 Requests per Second (RPS), and HAProxy can process 67676 RPS.
For a request size of 10 KB, NGINX can process 31964 Requests per Second (RPS), and HAProxy can process 31744 RPS.
For a request size of 500 KB, NGINX can process 763 Requests per Second (RPS), and HAProxy can process 767 RPS.
For a request size of 1 MB, NGINX can process 368 Requests per Second (RPS), and HAProxy can process 371 RPS.
Based on the results shown above, the performance is roughly the same, except as files that get requested get smaller in size, NGINX outpaces HAProxy strictly in terms of RPS. You can use the configurations above as a base to further performance tune NGINX or HAPROXY.
NGINX and HAProxy have a lot in common. They both do load balancing and they are much cheaper alternatives to other ADC vendors like F5 and Citrix netscaler. If you are just looking for a load balancer, HAProxy will do the job as it is more feature rich in load balancing functionality. If you are looking for more than just a load balancer like deliver static content at blazing speeds and advanced caching functionality, then you can go for NGINX.
Please note that both NGINX and HAPROXY have an enterprise versions of their open source offering. For more information, please visit www.nginx.com and haproxy.com.
Congratulations @rawdata! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
You published your First Post
Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here
If you no longer want to receive notifications, reply to this comment with the word
STOP
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit