mendhak / mendhak/docker-http-https-echo
Support for setting keepAliveTimeout
未關閉
還沒有人認領這個 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).`);
}
貢獻指南
這個儲存庫沒有索引到貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 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