9.3 Health Checks

Problem

You need to check the health of upstream UDP servers.

问题

检测 upstream 指令中的 UDP 服务器是否健康。


Solution

Use NGINX health checks with UDP load balancing to ensure only

healthy upstream servers are sent datagrams:

upstream ntp {
    server ntp1.example.com:123 max\_fails=3 fail\_timeout=3s;    
    server ntp2.example.com:123 max\_fails=3 fail\_timeout=3s;
}

This configuration passively monitors the upstream health, setting

the max_fails directive to 3, and fail_timeout to 3 seconds.

解决方案

对 UDP 负载均衡配置进行健康检测,确保只对正常运行的 UDP 服务器发送

数据报文:

upstream ntp {
    server ntp1.example.com:123 max\_fails=3 fail\_timeout=3s;    
    server ntp2.example.com:123 max\_fails=3 fail\_timeout=3s;
}

配置采用被动检测功能,将 max_fails 指令设置为 3 次,fail_timeout

设置为 3 秒。


Discussion

Health checking is important on all types of load balancing not only

from a user experience standpoint but also for business continuity.

NGINX can actively and passively monitor upstream UDP servers

to ensure they’re healthy and performing. Passive monitoring

watches for failed or timed-out connections as they pass through

NGINX. Active health checks send a packet to the specified port,

and can optionally expect a response.

结论

无论何种负载均衡,无论从用户体验角度,还是商业角度,健康检测都至关

重要。NGINX 同样提供 UDP 负载均衡主动和被动检测方案。被动检测会监测

连接失败及超时请求作为失效服务判断。主动检测会主动发送数据包值指定

端口,通过配置的预期响应判断服务是否有效。

results matching ""

    No results matching ""