After nginx down off one server

Test found problems and solutions

1, when the rear end two application servers are normal, very fast access, view logs, the original request, while the back-end server in response to two;

2, in order to mimic the fault testing, stopped an application server, the next time you visit, when you open a page request, found that half of the response is faster, the other half of the response is very slow, the last page is open, but the speed is not ideal, it is slow check error log and found that nginx or the server has been stopped half sent to the request, no wonder so slow; but soon (within 10 seconds) and then open when a page is requested, and very fast speed, view the log and found that server nginx will not have stopped half sent to the request; when after a while and then initiate a request, response appeared half and half faster response is very slow phenomenon, and view the log, nginx half sent to that server has again stopped the request;

3, here, I understand when checking back-end application server nginx health is how, should deal with this problem a time interval of it, when there is a back-end server down machine, the user has access not feel slow phenomenon ? In the original configuration in nginx load balancing can effectively solve this problem add the following two parameters:

upstream iisserver {

server 192.168.0.20:80 weight=5max_fails=2 fail_timeout=600s;

server 192.168.0.21:80 weight=5max_fails=2 fail_timeout=600s;

}

3.1) max_fails = NUMBER ---- (the time parameter provided fail_timeout) up to check whether the failed server is available requests generated within a certain period of time, the default is 1, can be set to 0 to close examination, these errors in proxy_next_upstream or fastcgi_next_upstream (404 max_fails error does not increase) as defined;

3.2) fail_timeout = TIME ---- max_fails produced after the failure of attempts to set the size of the connection request and the server may not be available at this time, the same time specifies the unavailable server (before the next attempt to initiate a connection request), the default is 10 seconds, fail_timeout and not directly related to the front end of the response time, but may be used to control proxy_connect_timeout and proxy_read_timeout.

I have 2 is provided when the request fails, it means that the backend server is unavailable, then the request will not be sent to the Nginx checked out the marked unavailable server at a later time 600S, test again, the rear end of a IIS application service service is stopped, but there appeared above phenomenon when you open a page request, the future will not appear within 10 minutes, the requested page open normal speed, value fail_timeout can be based on your actual situation.

Guess you like

Origin www.cnblogs.com/stj123/p/11004041.html