Detailed explanation of Nginx passively checking the server's survival status

Detailed explanation of Nginx passively checking the server's survival status

Nginx passively checks the server's liveness

introduce

Monitors the health of HTTP servers in the upstream group by sending periodic health checks. Nginx can continuously test your upstream servers, avoid failed servers, and gracefully add recovered servers to the load balancing group.

Passive health check

For passive health checking, Nginx monitors transactions as they occur and attempts to recover failed connections. If the transaction still cannot be recovered, Nginx marks the server as unavailable and temporarily stops sending requests to it until it is marked active again.

The conditions under which an upstream server is marked as unavailable are defined for each upstream server via the parameters of the server directive in the upstreams block:

  • fail_timeout : Sets how many failed attempts must occur for a server to be marked as unavailable, and how long the server is marked unavailable (default is 10 seconds).
  • max_fails : Sets the number of failed attempts that must occur during fail_timeout period in order for the server to be marked as unavailable (default is 1 attempt).

In the following example, Nginx will mark the server as unavailable within 30 seconds if it fails to send a request to the server or does not receive a response from the server 3 times within 30 seconds:

upstream backend {
    server backend1.example.com;
    server backend2.example.com max_fails=3 fail_timeout=30s;
}

NOTE : If there is only one server in the group, the fail_timeout and max_fails parameters are ignored and the server is never marked as unavailable.

Server slow start

A recently restored server can easily be overwhelmed with connections, which can cause the server to be marked unavailable again. Slow start allows an upstream server to gradually restore its weight from zero to its nominal value after it is restored or becomes available. This can be done with the slow_start parameter of the upstream server directive:

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

Note : If there is only one server in the group, the slow_start parameter is ignored and that server is never marked as unavailable. Slow start is unique to NGINX Plus (Business Edition).

This is the end of this article about Nginx passively checking the survival status of the server. For more relevant content about Nginx checking the survival status of the server, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed tutorial on how to deploy Springboot project using Nginx on the server (jar package)
  • How to use nginx to build a static resource server

<<:  Example code for using text-align and margin: 0 auto to center in CSS

>>:  The iframe frame sets the white background to transparent in IE browser

Recommend

Implementing a simple carousel based on JavaScript

This article shares the specific code of JavaScri...

Detailed explanation of meta tags (the role of meta tags)

No matter how wonderful your personal website is,...

How to compile and install xdebug in Ubuntu environment

This article describes how to compile and install...

What I learned while building my own blog

<br />In one year of blogging, I have person...

JS object copying (deep copy and shallow copy)

Table of contents 1. Shallow copy 1. Object.assig...

Explanation of the problem of selecting MySQL storage time type

The datetime type is usually used to store time i...

How to use a game controller in CocosCreator

Table of contents 1. Scene layout 2. Add a handle...

Connector configuration in Tomcat

JBoss uses Tomcat as the Web container, so the co...

Implementation of webpack code fragmentation

Table of contents background CommonsChunkPlugin s...

VMware virtual machine three connection methods example analysis

NAT In this way, the virtual machine's networ...

New settings for text and fonts in CSS3

Text Shadow text-shadow: horizontal offset vertic...

Detailed explanation of the use of Vue.js draggable text box component

Table of contents Registering Components Adding C...

3 ways to add links to HTML select tags

The first one : Copy code The code is as follows: ...