📜 ⬆️ ⬇️

ELB vs Nginx

Hi again!

I had a smart task for research, and I want to share my results with the community. The meaning of the problem is to determine the best NGINX deployment option in AWS EC2 / VPC. It should be the best from many sides, especially from the side of high availability and speed of response. Especially important factor is the speed of processing SSL requests, so tests for SSL performance were conducted.

All instances are on the same VPC network, ELB also rises on the same network.
')
Several variations of deployment were considered, but the choice fell on 2 main configurations, tests on which I conducted.

Configuration 1. ELB




Benefits:

Disadvantages:

Configuration 2. NGINX




Benefits:

Disadvantages:

Testing


Testing took place on m1.medium instances (3.75 GiB memory, 2 EC2 Compute Unit (1 virtual core with 2 EC2 Compute Unit)). As a web server, nginx with a default page was used. The test was conducted from another AWS region using Apache Bench: 6 competing users asked 400 times a page. The test was repeated 100 times in each case.

So, 4 tests were carried out. Both configurations responded to http and https requests.

Non-SSL


The tests are aimed at identifying the effect of ELB on the response rate of the structure. It is assumed that the configuration with the ELB will be slower to respond, because there is an additional node on the network. But you also need to take into account the fact that there can be more than one (in our case 2) NGINX instances that can be more productive than one for ELB.

Average Response Time Graph



The average result of all answers (in ms):
ELB: 209.586
NGINX: 207.934

findings

As you can see, the results are almost the same. Although the NGINX configuration on the graph is constantly faster than ELB, a difference of 1-2% is absolutely acceptable. And since the ELB configuration is much easier to configure, more stable and has almost the same response time as NGINX, we can give it preference.

SSL


Tests are aimed at finding out the performance of configurations regarding SSL encryption. In the ELB SSL configuration, encryption is performed by ELB; in the NGINX configuration, one NGINX balancer.

Average Response Time Graph



The average result of all answers (in ms):
ELB: 455.921
NGINX: 437.745

findings

At the beginning of testing, ELB was significantly behind in the responses. But after the 30th query, we see an increase in performance. This is because ELB has been vertically scaled. After increasing the computing power, the performance became almost the same, as can be seen from the graph.

As you know, ELB is a m1.micro instance that can be vertically scaled if it does not cope with the tasks. It is not controlled in any way and is done automatically. But, thanks to the partnership with AWS, you can achieve the installation of a minimum ELB shape, and for example, ELB will never be less than m1.medium. This is done in order to maximize the speed of the infrastructure. If you use this enterprise option, the choice of location for SSL encryption depends on the ease of configuration and other factors. So far these questions have not been considered, but the test results have shown that both configurations are approximately equivalent.

Afterword


Performance tests were performed on configurations with and without using ELB in AWS EC2 / VPC. Indicators suggest that the presence of an ELB has very little effect on response time, although it thereby facilitates the tuning of highly available solutions. Also, with the use of additional AWS options, it doesn’t matter in what place to handle SSL. In other cases, with sufficient power ( at least not t1.micro ), it should not be carried out at ELB.

If you have other interesting ideas on how to compare these configurations, I’m open to them. Now everything is running and you can easily run a few more tests.

UPD
Tests were conducted for HAproxy. As expected, HAproxy is slightly faster than NGINX.
Request average timing:

The overall picture is as follows:

Source: https://habr.com/ru/post/157425/


All Articles