3.0 Introduction
For a number of reasons, applications fail. It could be because of
network connectivity, server failure, or application failure, to name a
few. Proxies and load balancers must be smart enough to detect fail‐
ure of upstream servers and stop passing traffic to them; otherwise,
the client will be waiting, only to be delivered a timeout. A way to
mitigate service degradation when a server fails is to have the proxy
check the health of the upstream servers. NGINX offers two differ‐
ent types of health checks: passive, available in the open source ver‐
sion; as well as active, available only in NGINX Plus. Active health
checks on a regular interval will make a connection or request to the
upstream server and have the ability to verify that the response is
correct. Passive health checks monitor the connection or responses
of the upstream server as clients make the request or connection.
You may want to use passive health checks to reduce the load of
your upstream servers, and you may want to use active health
checks to determine failure of an upstream server before a client is
served a failure
3.0 简介
访问应用时,可能由于网络连接失败,Web 服务器宕机或应用程序异常等原因导致
应用程序无法访问。这时,代理或负载均衡器需要提供能够智能检测被代理或被负
载的 Web 服务是否无法访问的能力,来确保不会请求分发到这些失效的服务器。
同时,客户端会收到连接超时的响应,结束请求等待状态。
通过代理服务器向被代理服务器发送健康检测请求,来判断被代理服务器是否失效,是
一种减轻被代理服务器压力的有效方法。NGINX 服务器提供两种不同的健康检测方案:
被动检测和主动检测,开源版的 NGINX 提供被动检测功能, NGINX PLUS 提供主动检
测功能。主动检测的实现原理是,NGINX 代理服务向被代理服务器定时的发送连接请求,
如果被代理服务器正常响应,则说明被代理服务器正常运行。被动检测的实现原理是:
NGINX 服务器通过检测客户端发送的请求及被代理(被负载均衡)服务器的响应结果进行
判断被代理服务器是否失效。被动检测方案,可以有效降低被代理服务器的负载压力;
主动检测则能够在客户端发送请求之前,就能够剔除掉失效服务器。