Possible reason for NGINX 499 error codes

前端 未结 15 1686
没有蜡笔的小新
没有蜡笔的小新 2020-11-28 02:54

I\'m getting a lot of 499 NGINX error codes. I see that this is a client side issue. It is not a problem with NGINX or my uWSGI stack. I note the correlation in uWSGI log

15条回答
  •  旧时难觅i
    2020-11-28 03:34

    As you point 499 a connection abortion logged by the nginx. But usually this is produced when your backend server is being too slow, and another proxy timeouts first or the user software aborts the connection. So check if uWSGI is answering fast or not of if there is any load on uWSGI / Database server.

    In many cases there are some other proxies between the user and nginx. Some can be in your infrastructure like maybe a CDN, Load Balacer, a Varnish cache etc. Others can be in user side like a caching proxy etc.

    If there are proxies on your side like a LoadBalancer / CDN ... you should set the timeouts to timeout first your backend and progressively the other proxies to the user.

    If you have:

    user >>> CDN >>> Load Balancer >>> Nginx >>> uWSGI
    

    I'll recommend you to set:

    • n seconds to uWSGI timeout
    • n+1 seconds to nginx timeout
    • n+2 senconds to timeout to Load Balancer
    • n+3 seconds of timeout to the CDN.

    If you can't set some of the timeouts (like CDN) find whats is its timeout and adjust the others according to it (n, n-1...).

    This provides a correct chain of timeouts. and you'll find really whose giving the timeout and return the right response code to the user.

提交回复
热议问题