mendhak / mendhak/docker-http-https-echo

Support for setting keepAliveTimeout

未关闭
#103 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Shell
星标
792
派生
152
平均合并
3 天 18 小时
30 天内合并 PR
3

描述

Hi,

I was making some tests with the Echo container, including ensuring connection pool logics / configuration.
Currently this is taking the default 5s Node keepAliveTimeout which will then start dropping connections. If we would be able to stablish the keepAliveTimeout we would be able to allow the consumer side to manage the connections.

I've hacked a solution as:

// How long an idle keep-alive connection is held before the server closes it.
// Node's default is 5s, so an upstream keep-alive pool in front of this server can never be observed intact. 
// Raising it past the drain time lets the pool settle and leaves the reverse proxy in charge of trimming it.
const keepAliveTimeoutMs = parseInt(process.env.KEEPALIVE_TIMEOUT_MS, 10);
if (Number.isFinite(keepAliveTimeoutMs) && keepAliveTimeoutMs > 0) {
    for (const server of [httpServer, httpsServer]) {
        server.keepAliveTimeout = keepAliveTimeoutMs;
        // headersTimeout bounds how long a started request may take to send its headers; 
        // keeping it above keepAliveTimeout stops Node from closing a pooled connection just as it is being reused.
        server.headersTimeout = keepAliveTimeoutMs + 5000;
    }
    console.log(`Keep-alive timeout set to ${keepAliveTimeoutMs}ms (headers timeout ${keepAliveTimeoutMs + 5000}ms).`);
}

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

相关入口点是创建 httpServer 和 httpsServer 的 HTTP/HTTPS 服务器设置;首先跟踪 Echo 容器如何读取运行时环境变量。为两个服务器添加可配置的 keep-alive 超时,包括 issue 中展示的相关 headers-timeout 行为,并验证无论是否设置该配置,容器都仍能启动并接受 HTTP/S 请求。

由索引模型根据 Issue 内容生成。

评估

技术栈
docker, node.js
领域
backend
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
72/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。