1

I've using Nginx to load-balance a websocket app that runs in multiple Node.js instances. When there are thousands of active connections, a single message broadcast could make Node spin in place for seconds. During this time, Node wouldn't be handling incoming connections. To maintain the appearance of responsiveness even when the server is under heavy load, I want to have a spare process that only get used when the others don't respond quickly enough. I figured that marking one Node instance as "backup" would work:

upstream nodejs_backends {
    least_conn;

    server 127.0.0.1:5001;
    server 127.0.0.1:5002;
    server 127.0.0.1:5003;
    server 127.0.0.1:5004;
    server 127.0.0.1:5005;
    server 127.0.0.1:5006;
    server 127.0.0.1:5007;
    server 127.0.0.1:5008   backup; 
}

The backup instance is receiving request very rarely. Seems like Nginx is going through the upstream servers one by one. The backup server is only reached when all the others have been tried. Since least_conn is used, they're going to be even more swarmed than the first one. Nginx should just give up after the initial attempt and use the backup server. But I can't figure out how to make it happen in the version of Nginx I'm using (1.4). Any help or suggestion would be appreciated.

3
  • Sorry, what is your question? I think some text got lost. Jan 29, 2015 at 14:53
  • @AndrewSchulman Yeah, it got swallowed by weird coffeehouse wifi router. I've retyped.
    – cleong
    Jan 29, 2015 at 19:05
  • That's definition of backup server It will be passed requests when the primary servers are unavailable
    – Alexey Ten
    Jan 30, 2015 at 12:04

0

You must log in to answer this question.

Browse other questions tagged .