I could not find a solution for the issue so this is my question.
Say I have 3 servers, 2 of them are upstream servers, and 1 is a load balancer.
This is my basic configurations
Upstream servers
user www-data; worker_processes auto; pid /run/nginx.pid; events { worker_connections 768; } http { sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE ssl_prefer_server_ciphers on; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; gzip on; gzip_disable "msie6"; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; }
Load Balancer
worker_processes auto; worker_rlimit_nofile 100000; error_log off; events { worker_connections 5000; multi_accept on; use epoll; } http { upstream myapp1 { server 138.197.122.195; server 138.197.122.293; } server { listen 80; location / { proxy_pass http://myapp1; proxy_set_header X-Real-IP $ remote_addr; proxy_set_header X-Forwarded-For $ remote_addr; proxy_set_header Host $ host; } } }
What I want to achieve is to send/redirect users’ requests to the upstream servers using round robin load balancing feature of nginx. The upstreams will then serve content directly to users.
The role of load balancer here is not to reduce the load for upstreams by proxying, but to equally distribute requests to them. However, with these configurations all the requests & responses will go through the load balancer, consume its bandwidth. Is there another way to round robin redirect requests with NGINX? Please help.
The reason I want to do this is I have a limited bandwidth for a decent load balancer (high cost) thus cannot effectively scale. For example say 3 servers have 100mbps bandwidth each, if one user consumes 1mbps, the load balancer will be a bottleneck if there are 101 users. If I can distribute the traffic equally to both upstreams, the system can serve up to 200 users theoretically.
In most similar topic I found ppl using round robin DNS method. I tested it but it is not reliable because of record caching in the DNS hierarchy itself, as well as client-side address caching and reuse.