mendhak / mendhak/docker-http-https-echo
Support for setting keepAliveTimeout
Nobody has claimed this yet.
- Dominant language
- Shell
- Stars
- 792
- Forks
- 152
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 3
Description
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).`);
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The relevant entry point is the HTTP/HTTPS server setup that creates httpServer and httpsServer; start by tracing how the Echo container reads runtime environment variables. Add a configurable keep-alive timeout for both servers, including the related headers-timeout behavior shown in the issue, and verify that the container still starts and accepts HTTP/S requests with and without the setting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, node.js
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100