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

Detailed explanation of the use of various MySQL indexes

1. Slow query log 1.1 MySQL log types Logs are us...

JS implements click drop effect

js realizes the special effect of clicking and dr...

Introducing the code checking tool stylelint to share practical experience

Table of contents Preface text 1. Install styleli...

Example code for element multiple tables to achieve synchronous scrolling

Element UI implements multiple tables scrolling a...

CentOS method to modify the default ssh port number example

The default ssh port number of Linux servers is g...

CentOS7.x uninstall and install MySQL5.7 operation process and encoding format modification method

1. Uninstalling MySQL 5.7 1.1查看yum是否安裝過mysql cd y...

Use jQuery to fix the invalid page anchor point problem under iframe

The application scenario is: the iframe page has n...

MySQL cross-table query and cross-table update

Friends who have some basic knowledge of SQL must...

Use of Linux ln command

1. Command Introduction The ln command is used to...

Example code for implementing dotted border scrolling effect with CSS

We often see a cool effect where the mouse hovers...

A very detailed summary of communication between Vue components

Table of contents Preface 1. Props, $emit one-way...

An example of installing MySQL on Linux and configuring external network access

Configuration steps 1. Check whether DNS is confi...

Vue implements a simple shopping cart example

This article example shares the specific code of ...