nginx upstream problem

izghitu nginx-forum at nginx.us
Wed Apr 14 00:28:35 MSD 2010


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

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;
}


/etc/nginx/conf.d/upstrea-nonssl.conf

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;
   }
}


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

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,74663,74663#msg-74663




More information about the nginx mailing list