...

Open source softwares - NGINX

Back to Course

Lesson Description


Lession - #639 NGINX TCP Health Checks


NGINX TCP Health Checks

Nginx Plus and Nginx can consistently test our TCP upstream servers, keep away from the servers that have fizzled, and nimbly incorporate the recuperated servers into the heap adjusted bunch.
How about we see the arrangement of TCP wellbeing checks:
1. We have designed an upstream gathering of TCP servers in the stream setting, for example:

stream {  
    #...  
    upstream stream_backend {  
    server backend1.example.com:12345;  
    server backend2.example.com:12345;  
    server backend3.example.com:12345;  
   }  
    #...  
}  


2. We have configured a server that passes TCP connections to the server group:

stream {  
    #...  
    server {  
        listen     12345;  
        proxy_pass stream_backend;  
    }  
    #...  
}  


Passive TCP Health Checks

If an endeavor to interface with upstream server times out or brings about a mistake, Nginx Plus or Nginx open source can stamp the server as inaccessible and quit sending solicitations to it for a characterized measure of time. To decide the circumstances under which nginx considers an upstream server inaccessible, add the accompanying boundaries to the server mandate:
  • fail_timeout
  • max_fails

upstream stream_backend {  
    server backend1.example.com:12345 weight=5;  
    server backend2.example.com:12345 max_fails=2 fail_timeout=30s;  
    server backend3.example.com:12346 max_conns=3;  
}  


Server Slow Start

An upstream server can be effectively overpowered by associations, which might make the server be set apart as inaccessible once more. Slow beginning permits an upstream server to step by step recuperate its weight from zero to its ostensible worth after it has been recuperated or opened up. This should be possible with the slow_start boundary of the upstream server order:

upstream backend {  
    server backend1.example.com:12345 slow_start=30s;  
    server backend2.example.com;  
    server 192.0.0.1 backup;  
}  


Active TCP Health Checks

Health checks can be arranged to test a wide scope of disappointment types. For example Nginx Plus can ceaselessly take a look at upstream servers for responsiveness and stay away from servers that have fizzled. Nginx Plus sends unique wellbeing really take a look at solicitations to each upstream server and tests for a reaction that fulfills specific circumstances. In the event that an association with the server can't be laid out, the wellbeing check fizzles, and the server is thought of as undesirable. Nginx Plus doesn't intermediary associations of the clients to unfortunate servers. Assuming a few wellbeing checks are arranged for an upstream gathering, the disappointment of any wellbeing check is sufficient to consider the comparing server undesirable. To empower dynamic wellbeing checks: 1. Determine a common memory zone - An exceptional region where the Nginx Plus specialist processes share state data about associations and counters. Add the zone order to the upstream server bunch and characterize the zone (here, stream_backend>
and how much memory (64 KB>
.

stream {  
    #...  
    upstream stream_backend {  
        zone   stream_backend 64k;  
        server backend1.example.com:12345;  
        server backend2.example.com:12345;  
        server backend3.example.com:12345;  
    }  
    #...  
} 

2. Enable active health check for the upstream group with the health_check directive.

stream {  
    #...  
    server {  
        listen        12345;  
        proxy_pass    stream_backend;  
        health_check;  
        #...  
    }  
}  

3. Whenever required, decrease a break between two successive wellbeing checks with the health_check_timeout mandate. This health_check_timeout order supersedes the proxy_timeout an incentive for wellbeing checks, with respect to wellbeing checks, this break expects to be fundamentally more limited.

stream {  
    #...  
    server {  
        listen               12345;  
        proxy_pass           stream_backend;  
        health_check;  
        health_check_timeout 5s;  
    }  
}  

4. Of course, Nginx Plus sends wellbeing actually take a look at messages to the port indicated by the server order in the square of upstream. To supersede the port, characterize the port boundary of the health_check mandate.

stream {  
    #...  
    server {  
        listen               12345;  
        proxy_pass           stream_backend;  
        health_check         port=12346;  
        health_check_timeout 5s;  
    }  
}  


Fine Tuning TCP Health Checks

As a matter of course, Nginx Plus attempts to associate with every server in a gathering of upstream servers at regular intervals. In the event that the association can't be laid out, Nginx Plus considers the wellbeing checks fizzled, marks the server as undesirable, and quit sending client associations with the server.
To change the default conduct, add boundaries to the health_check mandate: interval: It characterizes how frequently Nginx Plus sends wellbeing actually look at demands in practically no time (default is 5 seconds>
.
passes: a few continuous wellbeing makes sure that the server should answer be viewed as sound. The default esteem is 1.
falls flat: a few sequential wellbeing makes sure that the server should neglect to answer be viewed as undesirable. The default esteem is 1.

stream {  
    #...  
    server {  
        listen       12345;  
        proxy_pass   stream_backend;  
        health_check interval=10 passes=2 fails=3;  
    }  
    #...  
}  


nginx proxy man redis rabbitmq

nginx proxy man redis rabbitmq

nginx 403 forbidden

nginx install ubuntu

nginx install ubuntu

where are nginx logs stored

As a matter of course, the entrance log is situated at/var/log/nginx/access. log , and the data is kept in touch with the sign in the predefined consolidated design. You can supersede the default settings and change the arrangement of logged messages by altering the NGINX design document (/and so on/nginx/nginx.

nginx logs

As a matter of course, the Nginx access log is situated at/var/log/nginx/access. log and the mistake log is situated at/var/log/nginx/blunder. log . Nginx logs record default way relies upon the working framework and establishment.

gcp console login nginx windows

gcp console login nginx windows