nginx automatic failover load balancing

157

Solution 1

I think that it's because nginx is not detecting that the upstream is down because it's on the same machine.

The options that you're looking for are: proxy_next_upstream and proxy_connect_timeout.

Try this:

location / {
        proxy_pass              http://lb;
        proxy_redirect          off;
        proxy_next_upstream     error timeout invalid_header http_500;
        proxy_connect_timeout   2;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
}

Solution 2

Hey, please see the wiki: http://wiki.nginx.org/NginxHttpUpstreamModule#server

Basically if a failure is detected the backend will be marked as down for x seconds and it will try again. So if you keep seeing connections it's probably nginx that keeps checking if the backend has become available.

It should, however, try the next entry in the upstream block, so you shouldn't actually see that no backends are available if only one is down.

Share:
157

Related videos on Youtube

Grymjack
Author by

Grymjack

Updated on September 17, 2022

Comments

  • Grymjack
    Grymjack over 1 year

    I have seven views that I need to navigate between from any of the other views. I don't want to keep doing segues from each one as new instances would keep being created...among other issues. What I was originally trying to do was have all the segues start from a home view and then go to the designated target view. When the user left that target view a public variable would be set if they wanted to go to any other view other than the home view. When the home view reappeared, it would check that public variable to see if another jump was needed. In the Home view I put the segue jump check in the -(void)viewDidAppear:(BOOL)animated function. The problem with this being you see the home screen for a second before it goes off to the new target view. The -(void)viewWillAppear:(BOOL)animated does not work for segues. I guess this is because it hasn't fully released the old segue yet?

    Is there a better way to handle a freeform many view navigation issue like this? If anyone needs it, I can post some sample code for what I was trying to do. Thanks in advance for any help.

    • lnafziger
      lnafziger over 11 years
      The most obvious answer would be to use a UITabBarController. Sounds like exactly what you need.
    • Grymjack
      Grymjack over 11 years
      Hmmm...I guess that I always associated the TabBars with web content. I appreciate the point in that direction. Now that I'm searching for tutorials in tab bar navigation, they are out there. [techotopia.com/index.php/…
    • lnafziger
      lnafziger over 11 years
      Yeah, they are definitely used for more than web content. A lot of iOS apps use them to organize different view controllers with a navigation like what you describe.
    • Grymjack
      Grymjack over 11 years
      If you want to put that in for an answer I will give you credit :)
  • Fernando García Redondo
    Fernando García Redondo about 12 years
    Why is proxy_redirect off?
  • Grymjack
    Grymjack over 11 years
    great answer! Thanks, saves me all the segue management and some screen real estate.