Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

120
Visualizações
node worker for loop slow between first and second iteration

I have a method that contains a for loop, and I have the main process and child processes calling this method.

20404 create:  2022-01-14 05:44:10.073
20404 create:  2022-01-14 05:44:10.075
20404 create:  2022-01-14 05:44:10.077
20404 create:  2022-01-14 05:44:10.077
send: 2022-01-14 05:44:10.078
send: 2022-01-14 05:44:10.079
send: 2022-01-14 05:44:10.079
16228 get  2022-01-14 05:44:10.081
11976 get  2022-01-14 05:44:10.081
9692 get  2022-01-14 05:44:10.082
11976 create:  2022-01-14 05:44:10.087
9692 create:  2022-01-14 05:44:10.087
16228 create:  2022-01-14 05:44:10.087
16228 create:  2022-01-14 05:44:10.113
9692 create:  2022-01-14 05:44:10.114
16228 create:  2022-01-14 05:44:10.116
11976 create:  2022-01-14 05:44:10.116
9692 create:  2022-01-14 05:44:10.117
16228 create:  2022-01-14 05:44:10.119
11976 create:  2022-01-14 05:44:10.121
11976 create:  2022-01-14 05:44:10.123

Above are logs, send is when main process sends the instruction to child process.

The first four lines are printed out from the main process, 2ms on average between every iteration

get is when a child process gets the instruction.

The first number is the process id. As you can see at this part:

11976 create:  2022-01-14 05:44:10.087
9692 create:  2022-01-14 05:44:10.087
16228 create:  2022-01-14 05:44:10.087
16228 create:  2022-01-14 05:44:10.113
9692 create:  2022-01-14 05:44:10.114
16228 create:  2022-01-14 05:44:10.116

The time gap between those two iterations is huge compared to the rest time gaps. Any ideas why this is happening?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

When I first created the child process the first run was always slow, so I had to send some dummy data to make it run a few times before it receives the actual data. In that way, when the actual request data comes in, the time gaps between iterations become small and consistent. Maybe it is just a node problem

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda