Welcome! Log In Create A New Profile

Advanced

nginx upstream problem

April 13, 2010 04:28PM
Hi,

I have several problems when using nginx as a load balancer.

Nginx 0.8.35
CentOS 5.4 64bit
Kernel 2.6.28.10

Configs:
/etc/nginx/nginx.conf
[code]
user nobody;
worker_processes 32;
worker_rlimit_nofile 10240;

error_log /var/log/nginx/error.log;

events {
use epoll;
accept_mutex off;
worker_connections 8192;
}


http {
include mime.types;
default_type application/octet-stream;

sendfile on;
tcp_nodelay on;
access_log off;
server_tokens off;
client_max_body_size 10m;

keepalive_timeout 65;

include /etc/nginx/conf.d/*.conf;
}
[/code]

/etc/nginx/conf.d/upstrea-nonssl.conf
[code]
upstream cloud {
server apache3 max_fails=1 fail_timeout=5;
server apache2 max_fails=1 fail_timeout=5;
server apache1 max_fails=1 fail_timeout=5;
}


server {
listen 1.1.1.1:80;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 30;
proxy_next_upstream error timeout;
proxy_pass http://cloud;
}
}
server {
listen 1.1.1.2:80;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 30;
proxy_next_upstream error timeout;
proxy_pass http://cloud;
}
}
[/code]

Problem 1:
Regardless of the order of the apache servers in the upstream, apache3 most of the time gets the lowest traffic. Sometimes it gets the same, sometimes it gets very few traffic.

Problem 2:
If I take down one apache server(halt or /etc/init.d/network stop) then I can see from the error log of nginx that it is still sending traffic to that apache server and I see time out or no route to host errors. When browsing the website I get waiting pages all the time which proves it tries to send to the apache server that is down.

Problem 3:
If I use the nginx fair module then the server that is listed last in the upstream, gets the highest amount of traffic.

Question 1:
How do I make nginx split the traffic equally between the 3 apache servers?

Question 2:
How do I make nginx not send traffic to an apache server that is down?

Please help

Thanks
Subject Author Posted

nginx upstream problem

izghitu April 13, 2010 04:28PM

Re: nginx upstream problem

Maxim Dounin April 13, 2010 06:10PM

Re: nginx upstream problem

izghitu April 13, 2010 06:19PM

Re: nginx upstream problem

izghitu April 14, 2010 10:45AM

Re: nginx upstream problem

Reinis Rozitis April 14, 2010 01:04PM

Re: nginx upstream problem

Maxim Dounin April 14, 2010 01:24PM

Re: nginx upstream problem

izghitu April 14, 2010 11:49AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 73
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready