Google负载均衡器会将请求随机失败 [英] Google Load-balancer randomly failing requests to backend
问题描述
后端(网站):
1台机器安装了tomcat,并在8080上提供服务。
webapps tomcat有两个文件夹
1 withGoogleRule1
| --test.html
2 withoutGoogleRule1
| --test.html
现在我有一个谷歌负载平衡器设置以下设置
现在后端机直接
ip是
$ b
LoadBalancer后台详细信息
只听8080而不是80,那么实例组,后端服务配置是有问题的。特别是,运行状况检查被配置为检查端口80,这将使负载平衡器认为后端服务不健康,并返回404.
另外,您可以检查Tomcat日志,看看收到了多少请求以及回复是什么。
编辑:由于您确认了另一个进程正在侦听80. 404 NOT FOUND的原因可能是,请求被内部调度到80.您可以通过在80和8080上托管一个页面来验证这个理论,例如/a.html,但内容不同,其中一个是我是80,另一个是我是8080。这样,你可以确切地知道发生了什么。检查在80上监听的进程的日志也可以提供帮助。
I had done simple setup:
Backend(website):
1 machine having tomcat installed and serving on 8080.
webapps folder of tomcat has two folder
1 withGoogleRule1
|--test.html
2 withoutGoogleRule1
|--test.html
Now i have a google-load-balancer setup with below settings
Now Backend machine direct
ip is http://104.197.37.171:8080/withoutGoogleRule1/test.html
Load Balancer url is http://107.178.240.39:8080/withoutGoogleRule1/test.html
PROBLEM:
No matter how many time we refresh url for direct machine, all requests always servers correctly.
But if you access url using load balancer 1 out of 5 time it shows
The requested URL /withoutGoogleRule1/test.html was not found on this server.
Details:
Youtube Video showing the failure of request
PS:
Instance group details:
LoadBalancer backend details
If your Tomcat was listening only on 8080 instead of 80, then the instance group, backend service configs were problematic. In particular, the health check was configured to check port 80, which would make the load balancer think the backend service was not healthy and return 404.
In addition, you can check Tomcat log to see how many requests were received and what were the responses.
Edit: Since you confirmed another process was listening on 80. The reason for 404 NOT FOUND could be, the requests were dispatched internally to 80. You can verify this theory by hosting a page on both 80 and 8080, e.g. /a.html, but the content is different, one is "i'm 80", the other is "i'm 8080". This way, you can know exactly what happened. Checking the log of the process listening on 80 can also help.
这篇关于Google负载均衡器会将请求随机失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!