Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

124
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!