mendhak / mendhak/docker-http-https-echo
Support for setting keepAliveTimeout
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Shell
- Star
- 792
- Fork
- 152
- Merge trung bình
- 3 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 3
Mô tả
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).`);
}
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Điểm vào liên quan là phần thiết lập máy chủ HTTP/HTTPS tạo httpServer và httpsServer; hãy bắt đầu bằng cách lần theo cách container Echo đọc các biến môi trường lúc chạy. Thêm thời gian chờ keep-alive có thể cấu hình cho cả hai máy chủ, bao gồm cả hành vi headers-timeout liên quan được nêu trong issue, và xác minh rằng container vẫn khởi động và chấp nhận các yêu cầu HTTP/S khi có và không có thiết lập này.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- docker, node.js
- Lĩnh vực
- backend
- Loại issue
- Tính năng
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 72/100