Skip to content

Balancing not working as expected #28

@VasilSvirid

Description

@VasilSvirid
const noroutine = require('noroutine');
const module1 = require('./module1.js');
const module2 = require('./module2.js);
noroutine.init({ modules: [module1, module2] });

(async () => {
  const res11 = await module1.method1('value1');
  const res12 = await module1.method2('value2');
  const res22 = await module2.method2('value21');
})();

actual: run one by one in different workers
expected: more suitable example

(async () => {
  const res11 = module1.method1('value1');
  const res12 = module1.method2('value2');
  const res22 = module2.method2('value21');

  await res11;
  await res12;
  await res22;
  // or Promise.all
})();

actual: functions run one by one in first worker 
expected: functions run in parallel 

worker utilization sample for http requests for default options:
actual:
1 -----__________-----
2 _____-----__________
3 __________-----_____
4 ____________________

expected:

1 -----------_------_-
2 _----_--------------
3 _-------------_-----
4 --------_-----------

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions