3
votes

We would like to set up NGINX behind ELB in AWS-EC2. The NGINX instances will be in a autoscaling group in multiple AZs to provide High availability. In this case, let's say there are 10 instances of backend servers which are loadbalanced by NGINX. How do the NGINX instances collaborate between themselves to provide more uniform loadbalancing across all 10 instances? If each NGINX instance acts in a silo, then the load distribution won't be uniform, for example if each of them decide to load balance to the same set of backend servers for whatver reason. I checked the white paper http://d0.awsstatic.com/whitepapers/AWS_NGINX_Plus-whitepaper-final_v4.pdf which describes the NGINX behind ELB briefly. The only reference is as below. Any more info will be very helpful to understand if this addresses the specific concerns of uniform distribution of requests.

Excerpt from white paper (http://d0.awsstatic.com/whitepapers/AWS_NGINX_Plus-whitepaper-final_v4.pdf)

To most accurately set up NGINX Plus for proxying WebSocket behind a load balancer, support for the PROXY protocol should be activated in the NGINX configuration. The NGINX configuration snippet below outlines an example of how to implement support for the PROXY protocol:

1
http { ... log_format elb_log '$proxy_protocol_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent "$http_referer" ' '"$http_user_agent"'; server { listen 80 proxy_protocol; set_real_ip_from 172.31.0.0/20; real_ip_header proxy_protocol; access_log /var/log/nginx/elb-access.log elb_log; location / { try_files $uri $uri/ /index.html; } } }SathiyaS
I couldn't add the code sample in main section due to some error checkSathiyaS

1 Answers

0
votes

if your goal is to 'provide more uniform loadbalancing across all 10 instances?' maybe you should check out Haproxy: https://github.com/markcaudill/haproxy-autoscale.

I use it to prevent stickiness from the ELB's and to load distribution uniformly between the servers.

Hope it was helpful.