使用 Google Cloud Kubernetes TCP 负载均衡器的 Nginx 状态码 499

Posted

技术标签:

【中文标题】使用 Google Cloud Kubernetes TCP 负载均衡器的 Nginx 状态码 499【英文标题】:Nginx Status Code 499 using Google Cloud Kubernetes TCP Load Balancer 【发布时间】:2020-03-28 15:38:11 【问题描述】:

我们在 GKE 上运行,使用在 TCP 负载均衡器下公开的面向公众的 nginx 入口控制器,该负载均衡器由 Kubernetes 自动配置。

问题是我们的请求中有 0.05% 的状态码为 499(Nginx 唯一的状态码,表示客户端已取消)。我们的 P99 延迟平均始终低于 100 毫秒。

【问题讨论】:

【参考方案1】:

此错误代码 499 与客户端浏览器在从后端发送响应之前关闭连接有关。

【讨论】:

【参考方案2】:

根据DerSkythe's answer

通过在配置映射中添加以下内容解决了我的问题。

apiVersion: v1
kind: ConfigMap
data:
  http-snippet: |
    proxy_ignore_client_abort on;

见http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_ignore_client_abort

开启此功能后,我的 499 错误几乎为零!

如果您遇到同样的问题,我强烈建议您尝试此配置。

【讨论】:

它解决了我的问题。我的设置有点不同,我在从 DC/OS 迁移后通过 Kubernetes 运行 NGINX 容器。我也有大约 1% 的流量下降,出现 499 个错误。我仍然不确定为什么忽略客户端中止选项会清除错误。我的意思是我希望我没有断开正确的连接。

以上是关于使用 Google Cloud Kubernetes TCP 负载均衡器的 Nginx 状态码 499的主要内容,如果未能解决你的问题,请参考以下文章

google.cloud.pubsub_v1 和 google.cloud.pubsub 有啥区别?

如何使用 Google Python Client for Cloud Functions 获取 Google Cloud Functions 列表?

kubernete的证书总结

Google Cloud 的使用

Google Cloud Messaging VS Google Cloud Platform

使用新的 Google Cloud 日志记录 jar 时,日志未显示在 Google Cloud Platform Stackdriver 中