Some 502 errors in GCP HTTP Load Balancing

后端 未结 3 1443
小鲜肉
小鲜肉 2021-01-01 12:43

Our load balancer is returning 502 errors for some requests. It is just a very low percentage of the total requests, we have around 36000 request per hour and about 40 error

3条回答
  •  鱼传尺愫
    2021-01-01 13:22

    It seems that there are no an easy solution for this.

    As Mike Fotinakis explains in this blog (thank you for this info JasonG :)):

    It turns out that there is a race condition between the Google Cloud HTTP(S) Load Balancer and NGINX’s default keep-alive timeout of 65 seconds. The NGINX timeout might be reached at the same time the load balancer tries to re-use the connection for another HTTP request, which breaks the connection and results in a 502 Bad Gateway response from the load balancer.

    In my case I'm using Apache with the mpm_prefork module. The solution proposed is to increase the connection keepalive timeout to 650s, but this is not possible because each connection opens one new process (so this would represent a great waste of resources).

    UPDATE:
    It seems that there are some new documentation about this problem on the official load balancer documentation page (search for "Timeouts and retries"): https://cloud.google.com/compute/docs/load-balancing/http/

    They recommend to set the KeepAliveTimeout value to 620 in both cases (Apache and Nginx).

提交回复
热议问题