nginx health checks

Nginx can be configured to monitor the health of backend server. 

1 Passive Health check

Nginix monitor the transications, and if the failed transaciton is failed, Nginx will stop sending request to it until it marked as active. 

fail_timeout , max_fails 

In the following example, if NGINX fails to send a request to a server or does not receive a response from it 3 times in 30 seconds, it marks the server as unavailable for 30 seconds:

upstream backend {
    server backend1.example.com; server backend2.example.com max_fails=3 fail_timeout=30s; }
Slow_start can be speicified in the server entry, so when the server is reabled, it allow the connection to grow slowly.

2 Active Health Checks

Nginx Plus can periodcally check the health of upstream server by sening health-check requests to each server 

Nginx can send requests for defined URL (it can be default url which user send request to, or a separate uri for healthy check only) periodcally and if the retrun code in  range of 200-399 , health check fails.  Nginx will block the client request to direct to this server until the health check is passed. 

User can speifiy the port for which nginx send request to.  Shared memory zone is used among all workers to kepp track of response from the server in the group . 

猜你喜欢

转载自www.cnblogs.com/anyu686/p/13401654.html