HAProxy random HTTP 503 errors

前端 未结 6 1061

We\'ve setup 3 servers:

  • Server A with Nginx + HAproxy to perform load balancing
  • backend server B
  • backend server C

Here is our

相关标签:
6条回答
  • 2020-12-29 08:46

    It is possible your servers share, perhaps, a common resource that is timing out at certain times, and that your health check requests are being made at the same time (and thus pulling the backend servers out at the same time).

    You can try using the HAProxy option spread-checks to randomize health checks.

    0 讨论(0)
  • 2020-12-29 08:49

    I had the same issue. After days of pulling my hair out I found the issue.

    I had two HAProxy instances running. One was a zombie that somehow never got killed during maybe an update or a haproxy restart. I noticed this when refreshing the /haproxy stats page and the PID would change between two different numbers. The page with one of the numbers had absurd connection stats. To confirm I did

    netstat -tulpn | grep 80
    

    and saw two haproxy processes listening to port 80.

    To fix the issue I did a "kill xxxx" where xxxx is the pid with the suspicious statistics.

    0 讨论(0)
  • 2020-12-29 08:54

    Hard to say without more details, but is it possible you are exceeding the configured maxconn for each backend? The Stats UI shows these stats on both the frontend and on individual backends.

    0 讨论(0)
  • 2020-12-29 08:59

    I resolved my intermittent 503s with HAProxy by adding option http-server-close to backend. Looks like uWSGI (which is upstream) is not doing well with keep-alive. Not sure what's really behind the problem, but after adding this option, haven't seen single 503 since.

    0 讨论(0)
  • 2020-12-29 09:10

    Adding my answer here for anyone else who encounters this exact same problem but none of the listed solutions above are applicable. Please note that my answer does not apply to the original code listed above.

    For anyone else who may have this problem, check your config and see if you might have mistakenly put the same "bind" line in multiple sections of your config. Haproxy does not check this during startup, and I plan to submit this as a recommended validation check to the developers. In my case, I have 3 different sections of the config, and I mistakenly put the same IP binding in two different places. It was about a 50/50 shot on whether or not the correct section would be used or the incorrect section was used. Even when the correct section was used, about half of the requests still got a 503.

    0 讨论(0)
  • 2020-12-29 09:10

    I had the same issue, due to 2 HAProxy services running in the linux box, but with different name/pid/resources. Unless i stop the unwanted one, the required instances throws 503 error randomly, say 1 in 5 times.

    Was trying to use single linux box for multiple URL routing but looks a limitation in haproxy or the config file of haproxy i have defined.

    0 讨论(0)
提交回复
热议问题