metarhia / noroutine

Goroutine analogue for Node.js, spreads I/O-bound routine calls to utilize thread pool (worker_threads) using balancer with event loop utilization. 🌱
https://metarhia.com
MIT License
121 stars 11 forks source link

Balancing not working as expected #28

Open VasilSvirid opened 2 years ago

VasilSvirid commented 2 years ago
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 --------_-----------
georgolden commented 1 year ago

@tshemsedinov @VasilSvirid is this issue fixed?

vsawake commented 1 year ago

(VasilSvirid) PR exits