mendhak / mendhak/docker-http-https-echo

Support for setting keepAliveTimeout

Aberta
#103 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Linguagem predominante
Shell
Estrelas
792
Forks
152
Merge médio
3d 18h
PRs com merge (30d)
3

Descrição

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).`);
}

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

O ponto de entrada relevante é a configuração do servidor HTTP/HTTPS que cria httpServer e httpsServer; comece rastreando como o contêiner Echo lê as variáveis de ambiente em tempo de execução. Adicione um timeout de keep-alive configurável para ambos os servidores, incluindo o comportamento relacionado de headers-timeout mostrado na issue, e verifique se o contêiner continua iniciando e aceitando solicitações HTTP/S com e sem a configuração.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
docker, node.js
Domínio
backend
Tipo de issue
Funcionalidade
Dificuldade
3/5
Tempo estimado
1-2 dias
Status de atividade
Pouca atividade
Clareza
Razoavelmente clara
Facilidade para iniciantes
72/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.