首页 > 解决方案 > 从池中获取连接 - Envoy

问题描述

我需要从池中获取连接以连接到上游,但偶尔会遇到 503 问题。我想知道这个的根本原因

https://github.com/envoyproxy/envoy/blob/master/source/common/router/router.cc

Http::ConnectionPool::Instance* conn_pool = getConnPool();
  if (!conn_pool) {
    sendNoHealthyUpstreamResponse();
    return Http::FilterHeadersStatus::StopIteration;
  }

这是导致 503 的代码部分。我尝试使用 while 循环重试固定次数,但仍然面临错误。有人可以指导找到根本原因或我该如何处理吗?

编辑:我怀疑的一个可能原因是特使方面经常发生排水。那么有没有办法可以控制发生排水的持续时间的drain_type?

我已按照此文档(https://www.envoyproxy.io/docs/envoy/latest/api-v1/listeners/listeners.html?highlight=draining%20modify_only)将drain_type从默认更改为modify_only。

但是面对这个错误:

error initializing configuration '/etc/envoy-config.json': JSON at lines 3-57 does not conform to schema.
 Invalid schema: #
 Schema violation: additionalProperties
 Offending document key: #/drain_type

标签: proxyhttp-status-code-503connection-poolenvoyproxy

解决方案


我尝试的一种解决方案是将 drain_timeout 增加到更大的值,例如 20 秒,而不是使用设置为 5 秒的默认值。这大大减少了我现在击中的 503 的数量,减少了 2 倍。另一方面,仍然未知.. 这种设置可能产生的副作用是什么仍有待探索,尽管它正在解决目前的目的。欢迎任何建议/意见/解决方案:)


推荐阅读